PIC assembly language beginners questions

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 code goes here ***

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


----> 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

Reply to
Loading thread data ...

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

Martin schrieb:

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

Reply to
Jochen Rapp

have a look at:

formatting link
this may help


Don McKenzie
E-Mail Contact Page:               http://www.dontronics.com/e-mail.html
 Click to see the full signature
Reply to
Don McKenzie

Hi Martin,

The book that tought me everything about PIC basic is this one...

formatting link

Click the sample chapter button on the right for a sample chapter from the book. I found it explains everything so clearly, it had me up and running in no time.


Reply to
Tim Duke

Take a look at

formatting link
This is where I started with PIC's. I've bought a few books from there. Their books are very good. Brian

Reply to


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:

formatting link

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.

Reply to
Anthony Fremont

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 :)

Reply to
David L. Jones

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.