Until now, when a function has parameters, from assembler these parameters
are accessed through IX, If I compare the asm of the two versions (3.1.0 and 3.2.0), I see
the 3.2.0 version omits the following:
push ix
ld ix,#0
add ix,sp
so access to the parameters, through IX, has unexpected results...
https://sourceforge.net/mailarchive/message.php?msg_id=29548243
Version:
SDCC : mcs51/gbz80/z80/z180/r2k/r3ka/ds390/pic16/pic14/TININative/ds400/hc08/s08 3.2.0 #8008 (Jul 6 2012) (MINGW32)
Sample Code:
///////////////////////////////////////////////////////////////////////////////////////////
void SetColor(unsigned char nColorIndex, unsigned char nPaletteIndex)
{
__asm
ld a, 4 (ix)
ld b, 5 (ix)
ld c, b
call #0xBC32 ;SCR SET INK
__endasm;
}
void main()
{
SetColor(1, 2);
}
///////////////////////////////////////////////////////////////////////////////////////////
if is compiled with "sdcc -mz80 bug.c":
;bug.c:1: void SetColor(unsigned char nColorIndex, unsigned char nPaletteIndex)
; ---------------------------------
; Function SetColor
; ---------------------------------
_SetColor_start::
_SetColor:
;bug.c:8: __endasm;
ld a, 4 (ix)
ld b, 5 (ix)
ld c, b
call #0xBC32 ;SCR SET INK
ret
_SetColor_end::
if is compiled with "sdcc --oldralloc -mz80 bug.c":
;bug.c:1: void SetColor(unsigned char nColorIndex, unsigned char nPaletteIndex)
; ---------------------------------
; Function SetColor
; ---------------------------------
_SetColor_start::
_SetColor:
push ix
ld ix,#0
add ix,sp
;bug.c:8: __endasm;
ld a, 4 (ix)
ld b, 5 (ix)
ld c, b
call #0xBC32 ;SCR SET INK
pop ix
ret
_SetColor_end::
Only with --oldralloc the parameters can be readed through IX. (Also on v3.1.0 this works perfectly)
In general, sdcc now decides using a heuristic if it should use a frame pointer, which has let to more compact code. However I see the need to specify this manually for purposes such as inline assembler.
In revision #8058 I implemented the --fno-omit-frame-pointer option for this.
Philipp