Skip to content

Commit 2d8ea7a

Browse files
authored
Merge pull request #837 from boriel-basic/fix/eq32_wrong
fix: neq32 had extra push af. Fixed.
2 parents 3aaa248 + 5c461ea commit 2d8ea7a

3 files changed

Lines changed: 81 additions & 1 deletion

File tree

src/arch/z80/backend/_32bit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def ne32(cls, ins: Quad) -> list[str]:
596596
597597
32 bit un/signed version
598598
"""
599-
output = cls.eq32(ins)
599+
output = cls.eq32(ins)[:-1] # Compare 32 bits, but do not push result
600600
output.append("sub 1") # Carry if A = 0 (False)
601601
output.append("sbc a, a") # Negates => !(A == B)
602602
output.append("push af")
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
org 32768
2+
.core.__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (.core.__CALL_BACK__), hl
12+
ei
13+
jp .core.__MAIN_PROGRAM__
14+
.core.__CALL_BACK__:
15+
DEFW 0
16+
.core.ZXBASIC_USER_DATA:
17+
; Defines USER DATA Length in bytes
18+
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
19+
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
20+
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
21+
_t:
22+
DEFB 00, 00, 00, 00
23+
.core.ZXBASIC_USER_DATA_END:
24+
.core.__MAIN_PROGRAM__:
25+
ld hl, (_t + 2)
26+
push hl
27+
ld hl, (_t)
28+
push hl
29+
ld de, 0
30+
ld hl, 0
31+
call .core.__EQ32
32+
sub 1
33+
sbc a, a
34+
ld (0), a
35+
ld hl, 0
36+
ld b, h
37+
ld c, l
38+
.core.__END_PROGRAM:
39+
di
40+
ld hl, (.core.__CALL_BACK__)
41+
ld sp, hl
42+
exx
43+
pop hl
44+
exx
45+
pop iy
46+
pop ix
47+
ei
48+
ret
49+
;; --- end of user code ---
50+
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/eq32.asm"
51+
push namespace core
52+
__EQ32: ; Test if 32bit value HLDE equals top of the stack
53+
; Returns result in A: 0 = False, FF = True
54+
exx
55+
pop bc ; Return address
56+
exx
57+
xor a ; Reset carry flag
58+
pop bc
59+
sbc hl, bc ; Low part
60+
ex de, hl
61+
pop bc
62+
sbc hl, bc ; High part
63+
exx
64+
push bc ; CALLEE
65+
exx
66+
ld a, h
67+
or l
68+
or d
69+
or e ; a = 0 and Z flag set only if HLDE = 0
70+
ld a, 1
71+
ret z
72+
xor a
73+
ret
74+
pop namespace
75+
#line 27 "arch/zx48k/neq32.bas"
76+
END
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
DIM t as Long
2+
3+
POKE 0, (t <> 0)
4+

0 commit comments

Comments
 (0)