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
28 changes: 14 additions & 14 deletions src/arch/z80/backend/_16bit.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,18 +1141,18 @@ def fparam16(cls, ins: Quad) -> list[str]:
"""
return Bits16.get_oper(ins[1])

@classmethod
def jnzero16(cls, ins: Quad) -> list[str]:
"""Jumps if top of the stack (16bit) is != 0 to arg(1)"""
value = ins[1]
if is_int(value):
if int(value) != 0:
return ["jp %s" % str(ins[2])] # Always true
else:
return []

def _jnzero16(ins: Quad) -> list[str]:
"""Jumps if top of the stack (16bit) is != 0 to arg(1)"""
value = ins[1]
if is_int(value):
if int(value) != 0:
return ["jp %s" % str(ins[2])] # Always true
else:
return []

output = Bits16.get_oper(value)
output.append("ld a, h")
output.append("or l")
output.append("jp nz, %s" % str(ins[2]))
return output
output = Bits16.get_oper(value)
output.append("ld a, h")
output.append("or l")
output.append("jp nz, %s" % str(ins[2]))
return output
9 changes: 3 additions & 6 deletions src/arch/z80/backend/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
# 16 bit comparison functions
# 16bit parameters and function call instrs
# 16 bit arithmetic functions
from ._16bit import (
Bits16,
_jnzero16,
)
from ._16bit import Bits16

# 32 bit bitwise operations
# 32 bit shift operations
Expand Down Expand Up @@ -316,8 +313,8 @@ def _set_quad_table(self):
ICInstruction.JZEROSTR: ICInfo(2, String.jzerostr), # if str is NULL or len(str) == 0, jmp LABEL
ICInstruction.JNZEROI8: ICInfo(2, Bits8.jnzero8), # if X != 0 jmp LABEL
ICInstruction.JNZEROU8: ICInfo(2, Bits8.jnzero8), # if X != 0 jmp LABEL
ICInstruction.JNZEROI16: ICInfo(2, _jnzero16), # if X != 0 jmp LABEL
ICInstruction.JNZEROU16: ICInfo(2, _jnzero16), # if X != 0 jmp LABEL
ICInstruction.JNZEROI16: ICInfo(2, Bits16.jnzero16), # if X != 0 jmp LABEL
ICInstruction.JNZEROU16: ICInfo(2, Bits16.jnzero16), # if X != 0 jmp LABEL
ICInstruction.JNZEROI32: ICInfo(2, Bits32.jnzero32), # if X != 0 jmp LABEL (32bit, fixed)
ICInstruction.JNZEROU32: ICInfo(2, Bits32.jnzero32), # if X != 0 jmp LABEL (32bit, fixed)
ICInstruction.JNZEROF16: ICInfo(2, Fixed16.jnzerof16), # if X != 0 jmp LABEL (32bit, fixed)
Expand Down