John Coppens wrote 2012-08-07 22:20: > Hi all. > > I'm in the midst of a hobby project, which grew larger than expected > (don't they always). > > My project has several relocatable modules, and I noticed some strange > things. Say main.asm and moda.asm both have a section 'udata' and both > define several registers. > > Now, if I declare something like this in mod_a.asm: > > gpr0 udata > reg1 res 5 > reg2 res 1 > > and then > > hdr equ reg1+0 > len equ reg1+1 > ... > I do not think you can mix RES symbols with EQU symbols that way. They are not of the same "type" so to speak. MPASM will give an error on this (even without "+0/1") : "Operand contains unresolvable labels or is too complex" Note that MPASM expects to know the value of the EQU (and SET) symbols during assembly-time, the RES symbols are not known until link-time (MPLINK or other linker). The value of reg1 is not important for MPASM (and probably GPASM). It's just a name it passes over to MPLINK (or GPLINK). But, a single UDATA section is always continus, so you can do: myvars udata reg1_hdr res 1 reg1_len res 1 reg1_rest res 3 reg2 res 1 And it will give you the same result, more or less. Note also that it is normaly "better" to not use "gpr0" as the name of the data section and let the linker decide the bank where to put the section. You have to BANKSEL anyway... Jan-Erik. > > then, hdr and len are always 0 based (not the address of reg1 + N). > The value of reg1 is correct - correctly appended to the gpr0 section > in main. > > It looks as if gplink doesn't correctly patch up the equs. > > Am I wrong in doing this? > > John > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .