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