Menu

#2304 long and float pointer - bad saving the upper two bytes

closed-fixed
None
Z80
7
2014-11-06
2014-10-30
No

The top two bytes for pointer datatype long or float are stored at address 0x000, or are completely omitted.

sdcc version:

sdcc -v

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:

sdcc -mz80 main.c

main.c:

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 ====

Truncated main.asm:

; 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 ====

1 Attachments

Discussion

  • Michal Hucik

    Michal Hucik - 2014-10-30

    main.asm

     
  • Maarten Brock

    Maarten Brock - 2014-10-31

    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.

     
  • Philipp Klaus Krause

    • Priority: 5 --> 7
     
  • Philipp Klaus Krause

    Increasing priority, since bad code is gerated silently (and also adding this to the issues-to-be-fixed-before-3.5.0-list).

    Philipp

     
  • Philipp Klaus Krause

    • assigned_to: Philipp Klaus Krause
     
  • Philipp Klaus Krause

    • status: open --> closed-fixed
     
  • Philipp Klaus Krause

    Fixed in revision #9094.

    Philipp

     

Log in to post a comment.