The .rel files generated by SDCC use 32-bit addresses for z80 (and related), 24 bits for stm8.
For stm8, #(_i >> 16) gives me the topmost byte of the 24-bit address. But for z80 I apparently get the least-significant byte of the address that way, i.e. as if the >> 16 wasn't even there. It looks to me like that when comparing the stm8 and z80 .rel files, though my understnading of hte asxxxx .rel format is limited; and I definitely see it in the final .ihx after linking.
I don't know what's going on with Z80 "long" addresses. I've tried this code to get some idea:
and I see the following generated for
-mz80:which gives in the
.lst:567Avalue hex, which is5678 + 2.We should be careful when we change the behavior, however. AFAIK there is various existing SDCC code already somehow using banks on z80 platforms.
I'll try to check on sdcc-user if anyone relies on the current behaviour. But I also found a bug report about it: [bugs:#2930].
Related
Bugs: #2930
From the one reaction on sdcc-user, apparently no one relies on current >> 24 behavior. So I'd suggest to make it behave for ez80/rabbit/tlcs90 as it does for stm8; if we do it for all z80-related, that would fix [bugs:#2930].
Related
Bugs: #2930