Maker Pro
Maker Pro

PIC assembly language beginners questions

M

Martin

Jan 1, 1970
0
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
 
J

Jochen Rapp

Jan 1, 1970
0
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
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.
Use CLRW thats the normal command
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"
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
 
D

Don McKenzie

Jan 1, 1970
0
Martin said:
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,

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
 
B

Brian

Jan 1, 1970
0
Martin said:
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

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
 
A

Anthony Fremont

Jan 1, 1970
0
Martin said:
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)

It would be defined in the include file for the specific PIC processor
you are using.
Also, there is an instruction "clrw" which directly clears W, rather
than the more general "clrf"
why would that not be used.

You are using an 18F series PIC it seems. The 16F series didn't have
WREG as an SFR.
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"

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

David L. Jones

Jan 1, 1970
0
Martin said:
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.

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