Page 1 of 1

accessing registers in asm

Posted: Thu May 29, 2008 8:04 am
by raghavmonga
i am having some difficulty in accessing the general purpose registers of pic for assembly level coding .

i am getting the error: error in built in assembly

do we need to access the registers through their RAM address or do we need the define the variables in flowcode or something else?
i have tried the former two but to no avail.


program in which external variable is used:
bsf _status,5 ;Go to bank 1
movlw 00h ;Put 00000 into W
movwf _trisb ;Move 00000 onto TRISA - all pins set to output
bcf _status,5 ;Come back to Bank 0
movlw AAh
movwf _FCV_A
addlw _FCV_A ,0
movwf _portb

program in which register address is used
bsf _status,5 ;Go to bank 1
movlw 00h ;Put 00000 into W
movwf _trisb ;Move 00000 onto TRISA - all pins set to output
bcf _status,5 ;Come back to Bank 0
movlw AAh
movwf 25h
addlw 25h,0
movwf _portb

both didn't work
plz help.
i am using Flowcode V3 for PIC

Re: accessing registers in asm

Posted: Thu May 29, 2008 10:18 am
by Benj
Hello

After compiling your code I was given a line number that indicated the problem was with the following line of code.

Code: Select all

addlw _FCV_A ,0
Changing the code to the following fixed the problem

Code: Select all

addwf _FCV_A ,0
So the completed code is now.

Code: Select all

asm{
bsf _status,5 ;Go to bank 1
movlw 00h ;Put 00000 into W
movwf _trisb ;Move 00000 onto TRISA - all pins set to output
bcf _status,5 ;Come back to Bank 0
movlw AAh
movwf _FCV_A
addwf _FCV_A ,0
movwf _portb
}

Re: accessing registers in asm

Posted: Mon Jun 02, 2008 7:36 am
by raghavmonga
Thanks Ben, that worked fine.
But i am still not able to access the registers using their respective addresses in the RAM.
please help

Re: accessing registers in asm

Posted: Mon Jun 02, 2008 12:20 pm
by Benj
Hello

You must use the register name. BoostC does not seem to support the direct register addresses.

Re: accessing registers in asm

Posted: Wed Jun 04, 2008 12:00 pm
by raghavmonga
but the general purpose registers in PIC don't have any name. they have to be used by using their addresses in RAM.

Re: accessing registers in asm

Posted: Wed Jun 04, 2008 1:49 pm
by Benj
Hello

Can you not use a variable instead then the compiler can assign the register dynamically.