Menu

#1677 muldiv fails under test-z80

closed-fixed
z80 port (189)
7
2013-05-25
2010-08-08
No

When using the rrz80 simulator from sdcc-extra the muldiv regression test fails:

gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.out:6:--- FAIL: "Assertion failed" on i/5 == 20 at gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.c:78
gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.out:7:--- FAIL: "Assertion failed" on i/25 == -2 at gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.c:85
gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.out:8:--- FAIL: "Assertion failed" on i/4 == -12 at gen/z80/muldiv/muldiv_storage_none_type_long_attr_volatile.c:89
gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.out:6:--- FAIL: "Assertion failed" on i/5 == 20 at gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.c:78
gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.out:7:--- FAIL: "Assertion failed" on i/25 == -2 at gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.c:85
gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.out:8:--- FAIL: "Assertion failed" on i/4 == -12 at gen/z80/muldiv/muldiv_storage_static_type_long_attr_volatile.c:89

Tested with svn revision 5917.

Discussion

  • Philipp Klaus Krause

    • priority: 5 --> 7
    • labels: 699367 -->
     
  • Philipp Klaus Krause

    It seems this is a bug in the Z80 port and in the ucz80 simulator.

    I've tried in two other emulators (xmess and Meka). On these emulators I see (int)(i/5) == -13087 for volatile signed long i = 100 using sdcc #5918.

    Philipp

     
  • Philipp Klaus Krause

    Hmm, the code sdcc #5919 generates for_divslong.c seems nonsensical:

    __divslong:
    push ix
    ld ix,#0
    add ix,sp
    ld hl,#-10
    add hl,sp
    ld sp,hl
    ;../_divslong.c:264: (y < 0 ? -y : y));
    ld a,11 (ix)
    jp PO,00113$

    ld doesn't affect the parity flag. The add hl, rr doesn't, add ix, rr doesnt. Neither does the push ix. Thus we jump depending on the value the parity flag had before entering the function.

    Philipp

     
  • Maarten Brock

    Maarten Brock - 2010-08-08

    Sorry, my fault. The check for PO in genCmp must only be performed when there were SUB/SBC opcodes before it. I can move it before the release label, but then the GameBoy code won't see it. But does the GBZ80 have a P flag with overflow functionality like the Z80?

     
  • Philipp Klaus Krause

    AFAIK the flag itself is there in the gbz80. However you can't use it for conditional jump / ret / call.

    Philipp

     
  • Maarten Brock

    Maarten Brock - 2010-08-08

    Fixed it for the Z80 in #5919. The GBZ80 will fail bug1757671.c regression test.

    The last opcode that modified the P/V flag before the call was probably INC 0(IY) for numTests++. Since the two test sets report a different number of tests and test cases I assume this resulted in the difference in the P/V flag. Otherwise there might still be a bug in the ucz80 simulator P/V flag.

     
  • Maarten Brock

    Maarten Brock - 2010-08-08
    • milestone: --> fixed
    • assigned_to: nobody --> maartenbrock
    • labels: --> z80 port
    • status: open --> closed-fixed
     

Log in to post a comment.