Connect with us

PIC assembly language beginners questions

Discussion in 'Electronic Basics' started by Martin, Aug 18, 2006.

Scroll to continue with content
  1. Martin

    Martin Guest

    I am trying to build some projects with some pics.

    I am self taught, and think I know the hardware end and C programing
    fairly well.
    But assembler is new to me, so I am trying to learn it.

    Before I ask my specific questions, a general one:
    Do you know of any general (or PIC targeted) assembly language
    tutorials,
    I have tried searching google, but tend to find lots of x86 tutorials


    I am currently trying to go through MPLabs tutorials, but their first
    example has brought up two questions.
    (I have copied the example below my questions)


    My first question is: the line
    clrf WREG
    clears the working register W if I understand correctly, where does the
    abbreviation WREG come from, is it a convention (that I would be
    unaware of)
    Also, there is an instruction "clrw" which directly clears W, rather
    than the more general "clrf"
    why would that not be used.

    The other question is: for the lines
    clrf COUNT,A ; initialize counter
    incf COUNT,F,A
    movf COUNT,W,A ; increase count and
    what is the "A"
    As I understand it, the variable count will point to a register, which
    holds the count, and F or W indicate the register to send the results
    to, but what is the "A"


    Thank you,

    Martin Bakalorz


    -------------------------------------------------------
    Snippet of assembler

    ;Start of main program
    ; The main program code is placed here.

    Main:

    ; *** main code goes here ***

    ----> clrf WREG
    movwf PORTC ; clear PORTC
    movwf TRISC ; configure PORTC as all outputs

    Init
    ----> clrf COUNT,A ; initialize counter
    IncCount
    ----> incf COUNT,F,A
    ----> movf COUNT,W,A ; increase count and
    movwf PORTC ; display on PORTC

    call Delay ; go to Delay subroutine
    goto IncCount ; infinite loop

    Delay
    movlw 0x40
    movwf DVAR2,A ; set outer delay loop
    DelayOuter
    movlw 0xFF
    movwf DVAR,A ; set inner delay loop
    DelayInner
    decfsz DVAR,F,A
    goto DelayInner

    decfsz DVAR2,F,A
    goto DelayOuter
    return
     
  2. Jochen Rapp

    Jochen Rapp Guest

    Hi Martin,
    If you Usind PIC 16XXX, get the Picmicro midrange reference manual.
    IN This manual you will find a documentation of the assembler.
    If you know C Programming, Try the Hitec- PICC compiler.
    regards Jochen
    Use CLRW thats the normal command
    A in the Destination, it#s one Bit
    Either, the destination is the Working-Register, otherwise the desination is count.
    Donload the midrange Refernce Manual, the Reference is better than thel Online
    help of MPLAB

    regards Jochen
     
  3. Don McKenzie

    Don McKenzie Guest

    have a look at:
    http://www.dontronics.com/see.html
    this may help

    Don...


    --
    Don McKenzie
    E-Mail Contact Page: http://www.dontronics.com/e-mail.html

    Micro,TTL,USB to 1.5" color LCD http://www.dontronics.com/micro-lcd.html
    USB,RS232 or TTL to VGA Monitor http://www.dontronics.com/micro-vga.html
    World's smallest USB 2 TTL Conv http://www.dontronics.com/micro-usb.html
     
  4. Tim Duke

    Tim Duke Guest

  5. Brian

    Brian Guest

    Take a look at http://www.sq-1.com/ This is where I started with PIC's.
    I've bought a few books from there. Their books are very good.
    Brian
     
  6. It would be defined in the include file for the specific PIC processor
    you are using.
    You are using an 18F series PIC it seems. The 16F series didn't have
    WREG as an SFR.
    It has to do with special features of the PIC 18F's and the way that
    banking is handled on that series.

    For the best book that I know of for using the PIC 18F, check here:
    www.picbook.com

    Allot of the code that you are likely to find on the net is for the
    older PICs like the 16F84 and such. The 18F' architecture is quite a
    bit different, in a more humane sort of way.
     
  7. Any particular reason why you are learning assembler if you already
    know C?
    There are free C compilers for the PIC available, one from HiTech and
    one from Microchip (18series PICs)

    C works just fine on PICs, no real need to go to assembler these days.

    Dave :)
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-