I am updating my inline assembly code to work with the changes in 4.2
and have test code to verify the changes. This does not seem related to
inline assembly, but what looks like an incorrect optimization.

Here is the source:
void test_number(char tnum)
{
    disp_clear();
    disp_curs(0);
    disp_putc(tnum + '0');
}

Here is the assembly output:
_test_number:
        push    a
        ld      (0x01, sp), a
;       test_bindec.c: 246: disp_clear();
        call    _tm1638_clear
;       test_bindec.c: 247: disp_curs(0);
        clr     a
        call    _tm1638_curs
;       test_bindec.c: 248: disp_putc(tnum + '0');
        ld      a, (0x01, sp)
        add     a, #0x30
        pop     a
        jp      _tm1638_putc
;       test_bindec.c: 249: }
        pop     a
        ret

Note that the last "pop a" and "ret" are unreachable. It looks like the
"call tm1638_putc" was replaced by "pop a" and "jp tm1638_putc".

Note that the correct value (tnum + 0x30) has been wiped out by the "pop
a". I suspect that the "pop a" was an (incorrect) optimization for "addw
sp, #1"

SDCC :
mcs51/z80/z180/r2k/r2ka/r3ka/sm83/tlcs90/ez80_z80/z80n/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8/pdk13/pdk14/pdk15/mos6502
4.2.0 #13081 (Linux)

Best regards,
-Richard


_______________________________________________
Sdcc-user mailing list
Sdcc-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sdcc-user

Reply via email to