diff --git a/src/arch/z80/backend/main.py b/src/arch/z80/backend/main.py index 6b10983b0..2a484713d 100644 --- a/src/arch/z80/backend/main.py +++ b/src/arch/z80/backend/main.py @@ -661,9 +661,7 @@ def emit_prologue() -> list[str]: output.append("exx") output.append("push hl") output.append("exx") - output.append("ld hl, 0") - output.append("add hl, sp") - output.append(f"ld ({common.CALL_BACK}), hl") + output.append(f"ld ({common.CALL_BACK}), sp") output.append("ei") output.extend(f"call {x}" for x in sorted(common.INITS)) diff --git a/src/arch/zxnext/backend/main.py b/src/arch/zxnext/backend/main.py index 16366df8d..21d2f0ddb 100644 --- a/src/arch/zxnext/backend/main.py +++ b/src/arch/zxnext/backend/main.py @@ -75,9 +75,7 @@ def emit_prologue() -> list[str]: output.append("di") output.append("push iy") output.append("ld iy, 0x5C3A ; ZX Spectrum ROM variables address") - output.append("ld hl, 0") - output.append("add hl, sp") - output.append(f"ld ({common.CALL_BACK}), hl") + output.append(f"ld ({common.CALL_BACK}), sp") output.append("ei") output.extend(f"call {x}" for x in sorted(common.INITS)) diff --git a/src/lib/arch/zx48k/runtime/arith/divf.asm b/src/lib/arch/zx48k/runtime/arith/divf.asm index d3b163fe4..5269f3f8c 100644 --- a/src/lib/arch/zx48k/runtime/arith/divf.asm +++ b/src/lib/arch/zx48k/runtime/arith/divf.asm @@ -27,9 +27,7 @@ ERR_SP EQU 23613 ld (TMP), hl ld hl, __DIVBYZERO push hl - ld hl, 0 - add hl, sp - ld (ERR_SP), hl + ld (ERR_SP), sp ; ------------- ROM DIV rst 28h diff --git a/src/lib/arch/zx48k/runtime/val.asm b/src/lib/arch/zx48k/runtime/val.asm index 3096db42b..22d9590a1 100644 --- a/src/lib/arch/zx48k/runtime/val.asm +++ b/src/lib/arch/zx48k/runtime/val.asm @@ -59,9 +59,7 @@ SET_MIN EQU 16B0h ;; Now put our error handler on ERR_SP ld hl, __VAL_ERROR push hl - ld hl, 0 - add hl, sp - ld (ERR_SP), hl + ld (ERR_SP), sp call STK_STO_S ; Enter it on the stack diff --git a/src/lib/arch/zxnext/runtime/arith/divf.asm b/src/lib/arch/zxnext/runtime/arith/divf.asm index d3b163fe4..5269f3f8c 100644 --- a/src/lib/arch/zxnext/runtime/arith/divf.asm +++ b/src/lib/arch/zxnext/runtime/arith/divf.asm @@ -27,9 +27,7 @@ ERR_SP EQU 23613 ld (TMP), hl ld hl, __DIVBYZERO push hl - ld hl, 0 - add hl, sp - ld (ERR_SP), hl + ld (ERR_SP), sp ; ------------- ROM DIV rst 28h diff --git a/src/lib/arch/zxnext/runtime/val.asm b/src/lib/arch/zxnext/runtime/val.asm index 3096db42b..22d9590a1 100644 --- a/src/lib/arch/zxnext/runtime/val.asm +++ b/src/lib/arch/zxnext/runtime/val.asm @@ -59,9 +59,7 @@ SET_MIN EQU 16B0h ;; Now put our error handler on ERR_SP ld hl, __VAL_ERROR push hl - ld hl, 0 - add hl, sp - ld (ERR_SP), hl + ld (ERR_SP), sp call STK_STO_S ; Enter it on the stack