ASM for dummies


Closed Thread
Results 1 to 10 of 10

Thread: ASM for dummies

Hybrid View

  1. #1
    carl_schell's Avatar
    carl_schell Guest


    Did you find this post helpful? Yes | No

    Cool

    Squibcakes -

    Hi. I found a book that I consider to be one of the best availible sources to beginners in ASM programming. It is:

    PIC In Practice by: David W. Smith

    a quick search at amazon.com should lead you to this book

    He does an outstanding job of taking you from knowing absolutely nothing about asm and pics to feeling like you could easily write lengthy programs in assembly. He has many projects in the book, such as LCD, A to D, EEPROM, Receivers and Transmitters and of course the blinky program. He uses 5 different pics to demonstrate with and gives very good directions, tips, ideas and encouragement.

    His book is actually what got me interested in PICs to begin with. It is a 240 page book that you will read cover to cover in 1 month...you will become addicted to it. It is very worth the $26 dollars I paid for it! However, in time you will probably drift back to pbp. But I think you will get a lot out of this book and learning a bit about assembly...kinda makes pbp easier to picture what is going on inside. Anyhow, enough of my speach...Best of luck to you

    Carl

    ------------------------------------------------------
    PIC Development Boards with Bootloader!

    www.schellelectronics.com
    ------------------------------------------------------

  2. #2
    i_am_tye's Avatar
    i_am_tye Guest


    Did you find this post helpful? Yes | No

    Default pic 16f870

    hi i used the code form this page and adapted it, thank you,
    it uses all 8 bits of portb and 2 bits of portc, the 2 bits of port c are used to multiplex 2 sets of 8 leds, so ya get 16 outputs. 3 shown here. what i want to know how could i impliment a lookup table for setting the data in port b and port c. i have shown 3 patterns in this code , but has 16, long code.
    please help driving me nuts, thought it may also help others who got to this section




    list P=PIC16F870 ; Tells MPASM the target processor

    include "p16f870.inc"

    __config _XT_OSC & _WDT_ON & _PWRTE_ON & _BODEN_ON & _LVP_OFF & _CPD_ON & _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF

    ; Tells MPASM our Configuration Fuse Definitions
    ;
    STATUS EQU 3h ;Define lable STATUS to 3
    PORTB EQU 6h ;Define lable PORTB to 6 (Bank 0)
    TRISB EQU 86h ;Define lable TRISB to 6 (Bank 1)
    PORTC EQU 7h ;Define lable PORTB to 6 (Bank 0)
    TRISC EQU 87h ;Define lable TRISB to 6 (Bank 1)
    ;

    COUNT_a EQU 20h ;Define lable COUNT_1 to RAM adress 20h
    COUNT_b EQU 21h ;Define lable COUNT_2 to RAM adress 21h
    DELAY EQU 22H

    ;
    STARTADR: ORG 000h ;Point to adress 000h which is the start adress
    GOTO START ;Jump over the fist adresses and to START
    ;
    ORG 010h ;Point to adress 010h.
    START: MOVLW b'00100000' ;Load W register so bank 1 will be set (see statusreg in datasheets)
    MOVWF STATUS ;Move W into STATUS and now Bank 1 will be selected
    MOVLW b'00000000' ;Load W with data direction for TRISB 1=input 0=output (binary for lights)
    MOVWF TRISB ;Move W into TRISB and RB0 will be an output(all outputs hehe =00000000)
    ;extra bits i added for setting trisc
    MOVLW b'11001111' ;Load W with data direction for TRISC 1=input 0=output (binary for lights)rc4 and rc5 as outputs
    MOVWF TRISC ;Move W into TRISC and RB0 will be an output(all outputs hehe =00000000)
    ;
    MOVLW b'00000000' ;Load W register so bank 0 will be set (see statusreg in datasheets)
    MOVWF STATUS ;Move W into STATUS and now Bank 0 will be selected
    ;

    BACK:
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;1st set led is 10000000 00000000
    ;port b is the pattern and port c is the bank
    ;
    MOVLW b'00000001' ;load pattern into W
    CALL ledbankleft ;load pattern into portb and select right led bank, ie port rc04

    MOVLW b'00000000' ;
    CALL ledbankright ; select right led bank, ie port rc05
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
    ;2nd set led is 110000000 00000000

    MOVLW b'00000011' ;
    CALL ledbankleft

    MOVLW b'00000000' ;
    CALL ledbankright
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;
    ;3nd set led is 11100000 00000000

    MOVLW b'00000111' ;
    CALL ledbankleft

    MOVLW b'00000000' ;
    CALL ledbankright
    GOTO BACK

    loop:
    MOVLW 07fh ;Load W with Loop time
    ; MOVLW DELAY
    MOVWF COUNT_a ;Move W to RAM adress
    ;
    NEXT_a: MOVLW 07fh ;Load W with Loop time
    MOVWF COUNT_b ;Move W to RAM adress
    NEXT_b: DECFSZ COUNT_b,F ;Decrease COUNT_2 and execute next instruction if result not zero.
    GOTO NEXT_b ;
    ;
    DECFSZ COUNT_a,F ;Decrease COUNT_1 and execute next instruction if result not zero.
    GOTO NEXT_a ;
    ;2ndloop
    MOVLW 07fh ;Load W with Loop time
    MOVWF COUNT_a ;Move W to RAM adress

    NEXT_c: MOVLW 07fh ;Load W with Loop time
    MOVWF COUNT_b ;Move W to RAM adress
    NEXT_d: DECFSZ COUNT_b,F ;Decrease COUNT_2 and execute next instruction if result not zero.
    GOTO NEXT_d ;
    ;
    DECFSZ COUNT_a,F ;Decrease COUNT_1 and execute next instruction if result not zero.
    GOTO NEXT_c ;
    RETURN

    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
    ledbankright: MOVWF PORTB
    MOVLW b'00100000' ;select led bank 1
    MOVWF PORTC ;Move W to port B and now RC5 will go Hi.
    CALL loop
    RETURN
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
    ledbankleft: MOVWF PORTB
    MOVLW b'00010000' ;select led bank 1
    MOVWF PORTC ;Move W to port B and now RC5 will go Hi.
    RETURN
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;
    END

  3. #3
    Join Date
    Jan 2007
    Posts
    78


    Did you find this post helpful? Yes | No

    Default

    Check out this PIC simulator software.
    Its around $40 U.S. and well worth it!!!
    The simulator is really awesome.
    If you know what having an oscilloscope does for you in terms of seeing whats going on inside a circuit. You'l find the same thing with this simulator.

    Its one of the best tools for playing with assembly I've found.

    InstPIC Simulator IDE official web site is on the following address:
    http://www.oshonsoft.com/alls and is up and running in a heart-beat.

Similar Threads

  1. PBP, ASM and LST files
    By HenrikOlsson in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 12th January 2010, 13:43
  2. ASM help
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 16
    Last Post: - 21st October 2009, 03:08
  3. ASM or PBP First?
    By mackrackit in forum Off Topic
    Replies: 4
    Last Post: - 10th October 2009, 12:08
  4. Serial Output - for an ASM numb
    By scomi85 in forum Serial
    Replies: 0
    Last Post: - 1st March 2009, 10:13
  5. Problem using ASM instruction
    By ewandeur in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 3rd April 2008, 15:26

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts