This is probably a dumb question. That's a good start, isn't it? ;-)
I want to create a jump table, so I started with:
jump_table: .byte pm_lo8(label1) .byte pm_lo8(label2) .byte pm_lo8(label3) . . .
That resulted in multiple:
Error: junk at end of line, first unrecognized character is `('
Huh. OK:
jump_table: .byte lo8(pm(label1)) .byte lo8(pm(label2)) .byte lo8(pm(label3)) . . .
Same errors.
Yes, I know my table lacks the high-byte of each label. That's intentional. The high byte of each will be the same, as each label will be in the same 256-word flash page, so I'll load ZH with an ldi and save some space in flash.
Some Googlin', and I found this unsatisfying conclusion:
https://lists.nongnu.org/archive/html/avr-gcc-list/2008-01/msg00169.html
I am wondering why something like this works: ldi r31, lo8(gs(foo)) and this not: .byte lo8(gs(foo))Why does as or ld (?) in the latter state it's not constant and the second is no problem?
After some more testing I found out that constructions like: .byte lo8(1024) are not allowed. Is this a bug?
This is from the last post in that thread.
A bit more noodling on my end, and I can guess that binutils was ust never meant to handle only part of a program memory address.
This works:
.byte lo8(label1)
... as does this:
.word pm(label1)
... but of course neither of those things gets me what I want: a jump table comprised of only the LSB of a number of program addresses suitable for use with ijmp.
My Googlin' Fu seems not up to the task of discovering how exactly I should be doing this, or if it is even possible with gas. The avr-gcc-list thread linked above makes some noises about building with dummy values, analysing the map file, injecting corrected addresses in place of the dummies, and building (or just linking again). This is equally unsatisfying.
Any guidance is appreciated. Suggestions that I abandon gas and switch to avrasm2 are unwelcome :-)
EDIT: added device tags