Need help with MPASM syntax for PIC18

Hello all. Trying to give a variable two different names. Right now, I have an array of variables declared thusly:

#DEFINE PARAMETER_BUFFER_SIZE 0X30 ;PARAMETER BUFFER SIZE #DEFINE PARAMETER1 0X00 #DEFINE PARAMETER2 0X01 #DEFINE PARAMETER3 0X02 ; ; and so on and so forth ; UDATA 0X100 PARAMETER_BUFFER RES PARAMETER_BUFFER_SIZE

Then I can access them in my program as

movwf PARAMETER_BUFFER+PARAMETER1, BANKED

However, this gets really annoying when trying to use the debugger watch window because address 0x100 shows the name PARAMETER_BUFFER and all addresses after that just show the address instead of a variable name. What I would like to do is be able to "redeclare" those same memory locations to be named something like

UDATA 0X100 fake_PARAMETER1 RES 1 fake_PARAMETER2 RES 1 fake_PARAMETER3 RES 1

but still leave it dynamically assigned. I've tried

UDATA 0X100 PARAMETER_BUFFER RES PARAMETER_BUFFER_SIZE UDATA 0X100 fake_PARAMETER1 RES 1

but I get the error "Each object file section must be contiguous (section .udata)". I've tried

#define fake_PARAMETER1_ADDR (PARAMETER_BUFFER+PARAMETER1) fake_PARAMETER1 equ fake_PARAMETER1_ADDR

but I get the error "Operand contains unresolvable labels or is too complex". Is there a way to do what I want without declaring every single variable's address statically?

-Will

Reply to
larkmore
Loading thread data ...

If you were writing in C then you may be able to acheive what you want with a union, but in assembler I don't know if there is an equivalent.

Dave.

Reply to
Dave

You should debug this. It has been a while since I used MPASM, but I assume the define works like the C preprocessor and should yield a suitable expression from the definitions above. Try using fake_PARAMETER1_ADDR in your instruction.

Is there a way to do what I want without declaring every

You could do something like

UDATA 0x100 PARAMETER_BUFFER equ $ ; start of buffer PARAMETER1 RES 1 PARAMETER2 RES 2 ... RES PARAMETER_BUFFER_SIZE-($-PARAMETER_BUFFER) ; remaining buffer

--
Thad
Reply to
Thad Smith

I think it does the right thing if you use CDATA instead of RES. Other than that, CDATA is an abomination that was obviously invented by someone with little experience with assemblers. It puts the assembler into a different mode until the end of the CDATA. Sigh.

Reply to
Eric Smith

I meant CBLOCK, not CDATA.

Reply to
Eric Smith

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.