Skip to content

Commit 2dbee30

Browse files
authored
Merge pull request #831 from bartsanchez/bart/move-jgezeroi16-to-a-class
ref: move jgezeroi16 function into a class (Bits16)
2 parents 36eb8b2 + 4b0d2dc commit 2dbee30

2 files changed

Lines changed: 14 additions & 15 deletions

File tree

src/arch/z80/backend/_16bit.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,20 +1102,20 @@ def jgezerou16(cls, ins: Quad) -> list[str]:
11021102
output.append("jp %s" % str(ins[2]))
11031103
return output
11041104

1105+
@classmethod
1106+
def jgezeroi16(cls, ins: Quad) -> list[str]:
1107+
"""Jumps if top of the stack (16bit) is >= 0 to arg(1)"""
1108+
value = ins[1]
1109+
if is_int(value):
1110+
if int(value) >= 0:
1111+
return ["jp %s" % str(ins[2])] # Always true
1112+
else:
1113+
return []
11051114

1106-
def _jgezeroi16(ins: Quad) -> list[str]:
1107-
"""Jumps if top of the stack (16bit) is >= 0 to arg(1)"""
1108-
value = ins[1]
1109-
if is_int(value):
1110-
if int(value) >= 0:
1111-
return ["jp %s" % str(ins[2])] # Always true
1112-
else:
1113-
return []
1114-
1115-
output = Bits16.get_oper(value)
1116-
output.append("add hl, hl") # Puts sign into carry
1117-
output.append("jp nc, %s" % str(ins[2]))
1118-
return output
1115+
output = Bits16.get_oper(value)
1116+
output.append("add hl, hl") # Puts sign into carry
1117+
output.append("jp nc, %s" % str(ins[2]))
1118+
return output
11191119

11201120

11211121
def _ret16(ins: Quad) -> list[str]:

src/arch/z80/backend/main.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
from ._16bit import (
3030
Bits16,
3131
_fparam16,
32-
_jgezeroi16,
3332
_jnzero16,
3433
_param16,
3534
_ret16,
@@ -329,7 +328,7 @@ def _set_quad_table(self):
329328
ICInstruction.JNZEROSTR: ICInfo(2, String.jnzerostr), # if str is not NULL and len(str) > 0, jmp LABEL
330329
ICInstruction.JGEZEROI8: ICInfo(2, Bits8.jgezeroi8), # if X >= 0 jmp LABEL
331330
ICInstruction.JGEZEROU8: ICInfo(2, Bits8.jgezerou8), # if X >= 0 jmp LABEL (ALWAYS TRUE)
332-
ICInstruction.JGEZEROI16: ICInfo(2, _jgezeroi16), # if X >= 0 jmp LABEL
331+
ICInstruction.JGEZEROI16: ICInfo(2, Bits16.jgezeroi16), # if X >= 0 jmp LABEL
333332
ICInstruction.JGEZEROU16: ICInfo(2, Bits16.jgezerou16), # if X >= 0 jmp LABEL (ALWAYS TRUE)
334333
ICInstruction.JGEZEROI32: ICInfo(2, Bits32.jgezeroi32), # if X >= 0 jmp LABEL (32bit, fixed)
335334
ICInstruction.JGEZEROU32: ICInfo(2, Bits32.jgezerou32), # if X >= 0 jmp LABEL (32bit, fixed) (always true)

0 commit comments

Comments
 (0)