Skip to content

Commit f096e7b

Browse files
authored
Merge pull request #829 from bartsanchez/bart/move-jzero16-to-a-class
ref: move jzero16 function into a class (Bits16)
2 parents 3fdc502 + c1a1eb1 commit f096e7b

2 files changed

Lines changed: 16 additions & 17 deletions

File tree

src/arch/z80/backend/_16bit.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1073,21 +1073,21 @@ def store16(cls, ins: Quad) -> list[str]:
10731073

10741074
return output
10751075

1076+
@classmethod
1077+
def jzero16(cls, ins: Quad) -> list[str]:
1078+
"""Jumps if top of the stack (16bit) is 0 to arg(1)"""
1079+
value = ins[1]
1080+
if is_int(value):
1081+
if int(value) == 0:
1082+
return ["jp %s" % str(ins[2])] # Always true
1083+
else:
1084+
return []
10761085

1077-
def _jzero16(ins: Quad) -> list[str]:
1078-
"""Jumps if top of the stack (16bit) is 0 to arg(1)"""
1079-
value = ins[1]
1080-
if is_int(value):
1081-
if int(value) == 0:
1082-
return ["jp %s" % str(ins[2])] # Always true
1083-
else:
1084-
return []
1085-
1086-
output = Bits16.get_oper(value)
1087-
output.append("ld a, h")
1088-
output.append("or l")
1089-
output.append("jp z, %s" % str(ins[2]))
1090-
return output
1086+
output = Bits16.get_oper(value)
1087+
output.append("ld a, h")
1088+
output.append("or l")
1089+
output.append("jp z, %s" % str(ins[2]))
1090+
return output
10911091

10921092

10931093
def _jgezerou16(ins: Quad) -> list[str]:

src/arch/z80/backend/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
_jgezeroi16,
3333
_jgezerou16,
3434
_jnzero16,
35-
_jzero16,
3635
_param16,
3736
_ret16,
3837
)
@@ -313,8 +312,8 @@ def _set_quad_table(self):
313312
ICInstruction.LENSTR: ICInfo(2, String.lenstr), # Gets strlen
314313
ICInstruction.JZEROI8: ICInfo(2, Bits8.jzero8), # if X == 0 jmp LABEL
315314
ICInstruction.JZEROU8: ICInfo(2, Bits8.jzero8), # if X == 0 jmp LABEL
316-
ICInstruction.JZEROI16: ICInfo(2, _jzero16), # if X == 0 jmp LABEL
317-
ICInstruction.JZEROU16: ICInfo(2, _jzero16), # if X == 0 jmp LABEL
315+
ICInstruction.JZEROI16: ICInfo(2, Bits16.jzero16), # if X == 0 jmp LABEL
316+
ICInstruction.JZEROU16: ICInfo(2, Bits16.jzero16), # if X == 0 jmp LABEL
318317
ICInstruction.JZEROI32: ICInfo(2, Bits32.jzero32), # if X == 0 jmp LABEL (32bit, fixed)
319318
ICInstruction.JZEROU32: ICInfo(2, Bits32.jzero32), # if X == 0 jmp LABEL (32bit, fixed)
320319
ICInstruction.JZEROF16: ICInfo(2, Fixed16.jzerof16), # if X == 0 jmp LABEL (32bit, fixed)

0 commit comments

Comments
 (0)