From e7b9c695d8016630f02bd5c62f68e2d5d75c57d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartolom=C3=A9=20S=C3=A1nchez=20Salado?= Date: Sun, 13 Oct 2024 21:23:57 +0200 Subject: [PATCH] ref: move jgezerou16 function into a class (Bits16) --- src/arch/z80/backend/_16bit.py | 22 +++++++++++----------- src/arch/z80/backend/main.py | 3 +-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/arch/z80/backend/_16bit.py b/src/arch/z80/backend/_16bit.py index 356d50c5d..21ab8fe4c 100644 --- a/src/arch/z80/backend/_16bit.py +++ b/src/arch/z80/backend/_16bit.py @@ -1089,18 +1089,18 @@ def jzero16(cls, ins: Quad) -> list[str]: output.append("jp z, %s" % str(ins[2])) return output + @classmethod + def jgezerou16(cls, ins: Quad) -> list[str]: + """Jumps if top of the stack (16bit) is >= 0 to arg(1) + Always TRUE for unsigned + """ + output = [] + value = ins[1] + if not is_int(value): + output = Bits16.get_oper(value) -def _jgezerou16(ins: Quad) -> list[str]: - """Jumps if top of the stack (16bit) is >= 0 to arg(1) - Always TRUE for unsigned - """ - output = [] - value = ins[1] - if not is_int(value): - output = Bits16.get_oper(value) - - output.append("jp %s" % str(ins[2])) - return output + output.append("jp %s" % str(ins[2])) + return output def _jgezeroi16(ins: Quad) -> list[str]: diff --git a/src/arch/z80/backend/main.py b/src/arch/z80/backend/main.py index c84c59fbc..62d84d078 100644 --- a/src/arch/z80/backend/main.py +++ b/src/arch/z80/backend/main.py @@ -30,7 +30,6 @@ Bits16, _fparam16, _jgezeroi16, - _jgezerou16, _jnzero16, _param16, _ret16, @@ -331,7 +330,7 @@ def _set_quad_table(self): ICInstruction.JGEZEROI8: ICInfo(2, Bits8.jgezeroi8), # if X >= 0 jmp LABEL ICInstruction.JGEZEROU8: ICInfo(2, Bits8.jgezerou8), # if X >= 0 jmp LABEL (ALWAYS TRUE) ICInstruction.JGEZEROI16: ICInfo(2, _jgezeroi16), # if X >= 0 jmp LABEL - ICInstruction.JGEZEROU16: ICInfo(2, _jgezerou16), # if X >= 0 jmp LABEL (ALWAYS TRUE) + ICInstruction.JGEZEROU16: ICInfo(2, Bits16.jgezerou16), # if X >= 0 jmp LABEL (ALWAYS TRUE) ICInstruction.JGEZEROI32: ICInfo(2, Bits32.jgezeroi32), # if X >= 0 jmp LABEL (32bit, fixed) ICInstruction.JGEZEROU32: ICInfo(2, Bits32.jgezerou32), # if X >= 0 jmp LABEL (32bit, fixed) (always true) ICInstruction.JGEZEROF16: ICInfo(2, Fixed16.jgezerof16), # if X >= 0 jmp LABEL (32bit, fixed)