MPLAB and gettting adresses of registres

Hi all

I am thinking of a way to used indirect addressing, using FSR and INDF.

In my code I have my memory like this (assembler)

something EQU 0x020 something1 EQU something+1 settings EQU something1+1 ; this will be 0x22

Is there a way to get the address as number?

MOVLW @something1 - which translates into MOVLW 0x21

Other assemblers have options like

LDA #$

Reply to
Sonnich Jensen
Loading thread data ...

Sorry I am not clear what you want. (1) Do you want W to get the address, that is 0x21 in your example. Or (2) do you want W to get the value of data that happens to be stored in file memory address 0x21?

If (1) then you have it already. If (2) try this: MOVLW something1 ; W is set to 0x21 MOVWF FSR ; pointer/indir reg is set to 0x21 . . . MOVF INDR,W ; W is set to the content 0..0xFF data stored in register pointed to by FSR. (Assuming that FSR has not been changed from 0x21 then W gets the content of memory location 0x21 in this example).

Handily INDR can be used in all sorts of other instructions too like DECFSZ, IORWF, RLF etc.

HTH piglet

Reply to
piglet

Thanks this is what I need!

I need to have some LED reaouts from 3 values, and my idea was to paas the address to a functions, which processes the data and return a value in W for me then to pass to the proper port

Thanks, I wonder why I didnt think of this. Then again at 1 o'clock at night...

Reply to
Sonnich Jensen
[snip]

return a value in W for me then to pass to the proper port

Depending on the PIC, and the nature of the data you use, the RETLW statement can build a nice (albeit static) indexed table for you as well.

Reply to
Randy Day

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.