The top two bytes for pointer datatype long or float are stored at address 0x000, or are completely omitted.
sdcc version:
SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.4.1 #9092 (Oct 27 2014) (Linux)
published under GNU General Public License (GPL)
Compilation args:
void main ( void )
{
signed long l = (signed long ) 0x6000;
float f = (float ) 0x7000;
*l++ = -2;
*l = 2;
*f++ = 10;
*f = 20;
}
==== end of main.c ====
; Function main
; ---------------------------------
_main_start::
_main:
;main.c:8: l++ = -2;
ld hl,#0xFFFE
ld (0x6000), hl
ld hl,#0xFFFF
ld (0x0000), hl ; 0x0000 addres is wrong
;main.c:9: l = 2;
ld hl,#0x0002
ld (0x6004), hl ; mising upper two bytes
;main.c:11: f++ = 10;
ld hl,#0x0000
ld (0x0000),hl
ld (0x7000), hl
ld hl,#0x4120
ld (0x0000), hl ; what? saved six bytes? 0x0000 addres is wrong
;main.c:12: f = 20;
ld hl,#0x0000
ld (0x7004), hl
ld hl,#0x41A0
ld (0x0000), hl ; 0x0000 addres is wrong
ret
==== end of main.asm ====
main.asm
The upper two bytes are not missing nor were six bytes saved for the float. Due to a peephole optimization the comment of line 11 just moved up a bit higher than you might have guessed.
The addresses still seem pretty wrong though.
Increasing priority, since bad code is gerated silently (and also adding this to the issues-to-be-fixed-before-3.5.0-list).
Philipp
Fixed in revision #9094.
Philipp