Skip to content

Commit 57aac95

Browse files
authored
Merge pull request #823 from bartsanchez/bart/move-shl16-to-a-class
ref: move shl16 function into a class (Bits16)
2 parents 13ffe86 + 1076da3 commit 57aac95

2 files changed

Lines changed: 37 additions & 38 deletions

File tree

src/arch/z80/backend/_16bit.py

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -959,47 +959,47 @@ def shri16(cls, ins: Quad) -> list[str]:
959959
output.append("push hl")
960960
return output
961961

962+
@classmethod
963+
def shl16(cls, ins: Quad) -> list[str]:
964+
"""Logical/aritmetical left shift 16bit (un)signed integer.
965+
The result is pushed onto the stack.
962966
963-
def _shl16(ins: Quad) -> list[str]:
964-
"""Logical/aritmetical left shift 16bit (un)signed integer.
965-
The result is pushed onto the stack.
966-
967-
Optimizations:
968-
* If 2nd op is 0 then
969-
do nothing
967+
Optimizations:
968+
* If 2nd op is 0 then
969+
do nothing
970970
971-
* If 2nd op is lower than 6
972-
unroll lop
973-
"""
974-
op1, op2 = tuple(ins[2:])
975-
label = tmp_label()
976-
label2 = tmp_label()
971+
* If 2nd op is lower than 6
972+
unroll lop
973+
"""
974+
op1, op2 = tuple(ins[2:])
975+
label = tmp_label()
976+
label2 = tmp_label()
977977

978-
if is_int(op2):
979-
op = int16(op2)
980-
if op == 0:
981-
return []
978+
if is_int(op2):
979+
op = int16(op2)
980+
if op == 0:
981+
return []
982982

983-
output = Bits16.get_oper(op1)
984-
if op < 6:
985-
output.extend(["add hl, hl"] * op)
986-
output.append("push hl")
987-
return output
983+
output = Bits16.get_oper(op1)
984+
if op < 6:
985+
output.extend(["add hl, hl"] * op)
986+
output.append("push hl")
987+
return output
988988

989-
output.append("ld b, %i" % op)
990-
else:
991-
output = Bits8.get_oper(op2)
992-
output.append("ld b, a")
993-
output.extend(Bits16.get_oper(op1))
994-
output.append("or a")
995-
output.append("jr z, %s" % label2)
989+
output.append("ld b, %i" % op)
990+
else:
991+
output = Bits8.get_oper(op2)
992+
output.append("ld b, a")
993+
output.extend(Bits16.get_oper(op1))
994+
output.append("or a")
995+
output.append("jr z, %s" % label2)
996996

997-
output.append("%s:" % label)
998-
output.append("add hl, hl")
999-
output.append("djnz %s" % label)
1000-
output.append("%s:" % label2)
1001-
output.append("push hl")
1002-
return output
997+
output.append("%s:" % label)
998+
output.append("add hl, hl")
999+
output.append("djnz %s" % label)
1000+
output.append("%s:" % label2)
1001+
output.append("push hl")
1002+
return output
10031003

10041004

10051005
def _load16(ins: Quad) -> list[str]:

src/arch/z80/backend/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
_load16,
3737
_param16,
3838
_ret16,
39-
_shl16,
4039
_store16,
4140
)
4241

@@ -207,8 +206,8 @@ def _set_quad_table(self):
207206
ICInstruction.SHLI8: ICInfo(3, Bits8.shl8),
208207
ICInstruction.SHRU16: ICInfo(3, Bits16.shru16),
209208
ICInstruction.SHRI16: ICInfo(3, Bits16.shri16),
210-
ICInstruction.SHLU16: ICInfo(3, _shl16),
211-
ICInstruction.SHLI16: ICInfo(3, _shl16),
209+
ICInstruction.SHLU16: ICInfo(3, Bits16.shl16),
210+
ICInstruction.SHLI16: ICInfo(3, Bits16.shl16),
212211
ICInstruction.SHRU32: ICInfo(3, Bits32.shru32),
213212
ICInstruction.SHRI32: ICInfo(3, Bits32.shri32),
214213
ICInstruction.SHLU32: ICInfo(3, Bits32.shl32),

0 commit comments

Comments
 (0)