Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/arch/z80/backend/_32bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ def ne32(cls, ins: Quad) -> list[str]:

32 bit un/signed version
"""
output = cls.eq32(ins)
output = cls.eq32(ins)[:-1] # Compare 32 bits, but do not push result
output.append("sub 1") # Carry if A = 0 (False)
output.append("sbc a, a") # Negates => !(A == B)
output.append("push af")
Expand Down
76 changes: 76 additions & 0 deletions tests/functional/arch/zx48k/neq32.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
org 32768
.core.__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld hl, 0
add hl, sp
ld (.core.__CALL_BACK__), hl
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_t:
DEFB 00, 00, 00, 00
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld hl, (_t + 2)
push hl
ld hl, (_t)
push hl
ld de, 0
ld hl, 0
call .core.__EQ32
sub 1
sbc a, a
ld (0), a
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
;; --- end of user code ---
#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/eq32.asm"
push namespace core
__EQ32: ; Test if 32bit value HLDE equals top of the stack
; Returns result in A: 0 = False, FF = True
exx
pop bc ; Return address
exx
xor a ; Reset carry flag
pop bc
sbc hl, bc ; Low part
ex de, hl
pop bc
sbc hl, bc ; High part
exx
push bc ; CALLEE
exx
ld a, h
or l
or d
or e ; a = 0 and Z flag set only if HLDE = 0
ld a, 1
ret z
xor a
ret
pop namespace
#line 27 "arch/zx48k/neq32.bas"
END
4 changes: 4 additions & 0 deletions tests/functional/arch/zx48k/neq32.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
DIM t as Long

POKE 0, (t <> 0)