From 20b4976f55483ba274aed5fdb582181c38ad7791 Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Wed, 13 Nov 2024 13:33:40 +0100 Subject: [PATCH] refact: move math runtime into math/ --- src/arch/z80/backend/runtime/labels.py | 8 +- src/arch/z80/backend/runtime/math.py | 18 +-- .../arch/zx48k/runtime/{ => math}/acos.asm | 1 - .../runtime => zx48k/runtime/math}/asin.asm | 1 - .../runtime => zx48k/runtime/math}/atan.asm | 1 - .../runtime => zx48k/runtime/math}/cos.asm | 1 - src/lib/arch/zx48k/runtime/{ => math}/exp.asm | 1 - .../arch/zx48k/runtime/{ => math}/logn.asm | 0 .../runtime => zx48k/runtime/math}/sin.asm | 1 - .../arch/zx48k/runtime/{ => math}/sqrt.asm | 1 - src/lib/arch/zx48k/runtime/{ => math}/tan.asm | 1 - .../arch/zxnext/runtime/{ => math}/acos.asm | 1 - .../runtime => zxnext/runtime/math}/asin.asm | 1 - .../runtime => zxnext/runtime/math}/atan.asm | 1 - .../runtime => zxnext/runtime/math}/cos.asm | 1 - .../arch/zxnext/runtime/{ => math}/exp.asm | 1 - .../arch/zxnext/runtime/{ => math}/logn.asm | 0 .../runtime => zxnext/runtime/math}/sin.asm | 1 - .../arch/zxnext/runtime/{ => math}/sqrt.asm | 1 - .../arch/zxnext/runtime/{ => math}/tan.asm | 1 - tests/functional/arch/zx48k/19.asm | 38 ++--- tests/functional/arch/zx48k/70.asm | 146 +++++++++--------- tests/functional/arch/zx48k/read10.asm | 54 +++---- tests/functional/arch/zx48k/read13.asm | 54 +++---- tests/functional/arch/zx48k/read4.asm | 52 +++---- tests/functional/arch/zx48k/read5.asm | 52 +++---- tests/functional/arch/zx48k/read8.asm | 52 +++---- tests/functional/arch/zx48k/read9.asm | 52 +++---- 28 files changed, 265 insertions(+), 277 deletions(-) rename src/lib/arch/zx48k/runtime/{ => math}/acos.asm (99%) rename src/lib/arch/{zxnext/runtime => zx48k/runtime/math}/asin.asm (99%) rename src/lib/arch/{zxnext/runtime => zx48k/runtime/math}/atan.asm (99%) rename src/lib/arch/{zxnext/runtime => zx48k/runtime/math}/cos.asm (99%) rename src/lib/arch/zx48k/runtime/{ => math}/exp.asm (99%) rename src/lib/arch/zx48k/runtime/{ => math}/logn.asm (100%) rename src/lib/arch/{zxnext/runtime => zx48k/runtime/math}/sin.asm (99%) rename src/lib/arch/zx48k/runtime/{ => math}/sqrt.asm (99%) rename src/lib/arch/zx48k/runtime/{ => math}/tan.asm (99%) rename src/lib/arch/zxnext/runtime/{ => math}/acos.asm (99%) rename src/lib/arch/{zx48k/runtime => zxnext/runtime/math}/asin.asm (99%) rename src/lib/arch/{zx48k/runtime => zxnext/runtime/math}/atan.asm (99%) rename src/lib/arch/{zx48k/runtime => zxnext/runtime/math}/cos.asm (99%) rename src/lib/arch/zxnext/runtime/{ => math}/exp.asm (99%) rename src/lib/arch/zxnext/runtime/{ => math}/logn.asm (100%) rename src/lib/arch/{zx48k/runtime => zxnext/runtime/math}/sin.asm (99%) rename src/lib/arch/zxnext/runtime/{ => math}/sqrt.asm (99%) rename src/lib/arch/zxnext/runtime/{ => math}/tan.asm (99%) diff --git a/src/arch/z80/backend/runtime/labels.py b/src/arch/z80/backend/runtime/labels.py index fb625a986..b9359048d 100644 --- a/src/arch/z80/backend/runtime/labels.py +++ b/src/arch/z80/backend/runtime/labels.py @@ -1,4 +1,6 @@ # Runtime Labels +from typing import Final + from . import core, datarestore, io, math, misc, random from .namespace import NAMESPACE @@ -16,7 +18,9 @@ class Labels( NAMESPACE = NAMESPACE -RUNTIME_LABELS: set[str] = {getattr(Labels, x) for x in dir(Labels) if not x.startswith("__") and x != "NAMESPACE"} +RUNTIME_LABELS: Final[set[str]] = { + getattr(Labels, x) for x in dir(Labels) if not x.startswith("__") and x != "NAMESPACE" +} def _dict_join(*args: dict[str, str]) -> dict[str, str]: @@ -32,7 +36,7 @@ def _dict_join(*args: dict[str, str]) -> dict[str, str]: return result -LABEL_REQUIRED_MODULES = _dict_join( +LABEL_REQUIRED_MODULES: Final[dict[str, str]] = _dict_join( core.REQUIRED_MODULES, datarestore.REQUIRED_MODULES, math.REQUIRED_MODULES, diff --git a/src/arch/z80/backend/runtime/math.py b/src/arch/z80/backend/runtime/math.py index fc7b58eaf..e91bcb435 100644 --- a/src/arch/z80/backend/runtime/math.py +++ b/src/arch/z80/backend/runtime/math.py @@ -26,15 +26,15 @@ class MathLabels: REQUIRED_MODULES = { - MathLabels.ACS: "acos.asm", - MathLabels.ASN: "asin.asm", - MathLabels.ATN: "atan.asm", - MathLabels.COS: "cos.asm", - MathLabels.SIN: "sin.asm", - MathLabels.TAN: "tan.asm", - MathLabels.EXP: "exp.asm", - MathLabels.LN: "logn.asm", - MathLabels.SQR: "sqrt.asm", + MathLabels.ACS: "math/acos.asm", + MathLabels.ASN: "math/asin.asm", + MathLabels.ATN: "math/atan.asm", + MathLabels.COS: "math/cos.asm", + MathLabels.SIN: "math/sin.asm", + MathLabels.TAN: "math/tan.asm", + MathLabels.EXP: "math/exp.asm", + MathLabels.LN: "math/logn.asm", + MathLabels.SQR: "math/sqrt.asm", MathLabels.SGNI8: "sgni8.asm", MathLabels.SGNU8: "sgnu8.asm", MathLabels.SGNI16: "sgni16.asm", diff --git a/src/lib/arch/zx48k/runtime/acos.asm b/src/lib/arch/zx48k/runtime/math/acos.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/acos.asm rename to src/lib/arch/zx48k/runtime/math/acos.asm index b2030df2f..36f7169ad 100644 --- a/src/lib/arch/zx48k/runtime/acos.asm +++ b/src/lib/arch/zx48k/runtime/math/acos.asm @@ -12,4 +12,3 @@ ACOS: ; Computes ACOS using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/asin.asm b/src/lib/arch/zx48k/runtime/math/asin.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/asin.asm rename to src/lib/arch/zx48k/runtime/math/asin.asm index 598bafb3d..a41b236b7 100644 --- a/src/lib/arch/zxnext/runtime/asin.asm +++ b/src/lib/arch/zx48k/runtime/math/asin.asm @@ -12,4 +12,3 @@ ASIN: ; Computes ASIN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/atan.asm b/src/lib/arch/zx48k/runtime/math/atan.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/atan.asm rename to src/lib/arch/zx48k/runtime/math/atan.asm index 83eb2c3b3..c73b56939 100644 --- a/src/lib/arch/zxnext/runtime/atan.asm +++ b/src/lib/arch/zx48k/runtime/math/atan.asm @@ -12,4 +12,3 @@ ATAN: ; Computes ATAN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/cos.asm b/src/lib/arch/zx48k/runtime/math/cos.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/cos.asm rename to src/lib/arch/zx48k/runtime/math/cos.asm index 36739c87f..4a62f1947 100644 --- a/src/lib/arch/zxnext/runtime/cos.asm +++ b/src/lib/arch/zx48k/runtime/math/cos.asm @@ -12,4 +12,3 @@ COS: ; Computes COS using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/exp.asm b/src/lib/arch/zx48k/runtime/math/exp.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/exp.asm rename to src/lib/arch/zx48k/runtime/math/exp.asm index d1a439e2f..052b38984 100644 --- a/src/lib/arch/zx48k/runtime/exp.asm +++ b/src/lib/arch/zx48k/runtime/math/exp.asm @@ -12,4 +12,3 @@ EXP: ; Computes e^n using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/logn.asm b/src/lib/arch/zx48k/runtime/math/logn.asm similarity index 100% rename from src/lib/arch/zx48k/runtime/logn.asm rename to src/lib/arch/zx48k/runtime/math/logn.asm diff --git a/src/lib/arch/zxnext/runtime/sin.asm b/src/lib/arch/zx48k/runtime/math/sin.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/sin.asm rename to src/lib/arch/zx48k/runtime/math/sin.asm index bf76718da..59ed05661 100644 --- a/src/lib/arch/zxnext/runtime/sin.asm +++ b/src/lib/arch/zx48k/runtime/math/sin.asm @@ -12,4 +12,3 @@ SIN: ; Computes SIN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/sqrt.asm b/src/lib/arch/zx48k/runtime/math/sqrt.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/sqrt.asm rename to src/lib/arch/zx48k/runtime/math/sqrt.asm index eac9a50c9..4ddbc1b54 100644 --- a/src/lib/arch/zx48k/runtime/sqrt.asm +++ b/src/lib/arch/zx48k/runtime/math/sqrt.asm @@ -12,4 +12,3 @@ SQRT: ; Computes SQRT(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/tan.asm b/src/lib/arch/zx48k/runtime/math/tan.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/tan.asm rename to src/lib/arch/zx48k/runtime/math/tan.asm index ef3de4c95..4da8c9414 100644 --- a/src/lib/arch/zx48k/runtime/tan.asm +++ b/src/lib/arch/zx48k/runtime/math/tan.asm @@ -12,4 +12,3 @@ TAN: ; Computes TAN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/acos.asm b/src/lib/arch/zxnext/runtime/math/acos.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/acos.asm rename to src/lib/arch/zxnext/runtime/math/acos.asm index b2030df2f..36f7169ad 100644 --- a/src/lib/arch/zxnext/runtime/acos.asm +++ b/src/lib/arch/zxnext/runtime/math/acos.asm @@ -12,4 +12,3 @@ ACOS: ; Computes ACOS using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/asin.asm b/src/lib/arch/zxnext/runtime/math/asin.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/asin.asm rename to src/lib/arch/zxnext/runtime/math/asin.asm index 598bafb3d..a41b236b7 100644 --- a/src/lib/arch/zx48k/runtime/asin.asm +++ b/src/lib/arch/zxnext/runtime/math/asin.asm @@ -12,4 +12,3 @@ ASIN: ; Computes ASIN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/atan.asm b/src/lib/arch/zxnext/runtime/math/atan.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/atan.asm rename to src/lib/arch/zxnext/runtime/math/atan.asm index 83eb2c3b3..c73b56939 100644 --- a/src/lib/arch/zx48k/runtime/atan.asm +++ b/src/lib/arch/zxnext/runtime/math/atan.asm @@ -12,4 +12,3 @@ ATAN: ; Computes ATAN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zx48k/runtime/cos.asm b/src/lib/arch/zxnext/runtime/math/cos.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/cos.asm rename to src/lib/arch/zxnext/runtime/math/cos.asm index 36739c87f..4a62f1947 100644 --- a/src/lib/arch/zx48k/runtime/cos.asm +++ b/src/lib/arch/zxnext/runtime/math/cos.asm @@ -12,4 +12,3 @@ COS: ; Computes COS using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/exp.asm b/src/lib/arch/zxnext/runtime/math/exp.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/exp.asm rename to src/lib/arch/zxnext/runtime/math/exp.asm index d1a439e2f..052b38984 100644 --- a/src/lib/arch/zxnext/runtime/exp.asm +++ b/src/lib/arch/zxnext/runtime/math/exp.asm @@ -12,4 +12,3 @@ EXP: ; Computes e^n using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/logn.asm b/src/lib/arch/zxnext/runtime/math/logn.asm similarity index 100% rename from src/lib/arch/zxnext/runtime/logn.asm rename to src/lib/arch/zxnext/runtime/math/logn.asm diff --git a/src/lib/arch/zx48k/runtime/sin.asm b/src/lib/arch/zxnext/runtime/math/sin.asm similarity index 99% rename from src/lib/arch/zx48k/runtime/sin.asm rename to src/lib/arch/zxnext/runtime/math/sin.asm index bf76718da..59ed05661 100644 --- a/src/lib/arch/zx48k/runtime/sin.asm +++ b/src/lib/arch/zxnext/runtime/math/sin.asm @@ -12,4 +12,3 @@ SIN: ; Computes SIN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/sqrt.asm b/src/lib/arch/zxnext/runtime/math/sqrt.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/sqrt.asm rename to src/lib/arch/zxnext/runtime/math/sqrt.asm index eac9a50c9..4ddbc1b54 100644 --- a/src/lib/arch/zxnext/runtime/sqrt.asm +++ b/src/lib/arch/zxnext/runtime/math/sqrt.asm @@ -12,4 +12,3 @@ SQRT: ; Computes SQRT(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/src/lib/arch/zxnext/runtime/tan.asm b/src/lib/arch/zxnext/runtime/math/tan.asm similarity index 99% rename from src/lib/arch/zxnext/runtime/tan.asm rename to src/lib/arch/zxnext/runtime/math/tan.asm index ef3de4c95..4da8c9414 100644 --- a/src/lib/arch/zxnext/runtime/tan.asm +++ b/src/lib/arch/zxnext/runtime/math/tan.asm @@ -12,4 +12,3 @@ TAN: ; Computes TAN using ROM FP-CALC jp __FPSTACK_POP pop namespace - diff --git a/tests/functional/arch/zx48k/19.asm b/tests/functional/arch/zx48k/19.asm index 1fd3777bd..9fc8999af 100644 --- a/tests/functional/arch/zx48k/19.asm +++ b/tests/functional/arch/zx48k/19.asm @@ -91,7 +91,7 @@ _x: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/acos.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/acos.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -131,7 +131,7 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/acos.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/acos.asm" push namespace core ACOS: ; Computes ACOS using ROM FP-CALC call __FPSTACK_PUSH @@ -141,7 +141,7 @@ ACOS: ; Computes ACOS using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 71 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/asin.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/asin.asm" push namespace core ASIN: ; Computes ASIN using ROM FP-CALC call __FPSTACK_PUSH @@ -151,7 +151,7 @@ ASIN: ; Computes ASIN using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 72 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/atan.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/atan.asm" push namespace core ATAN: ; Computes ATAN using ROM FP-CALC call __FPSTACK_PUSH @@ -161,7 +161,7 @@ ATAN: ; Computes ATAN using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 73 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/cos.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/cos.asm" push namespace core COS: ; Computes COS using ROM FP-CALC call __FPSTACK_PUSH @@ -171,7 +171,7 @@ COS: ; Computes COS using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 74 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/exp.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/exp.asm" push namespace core EXP: ; Computes e^n using ROM FP-CALC call __FPSTACK_PUSH @@ -181,7 +181,7 @@ EXP: ; Computes e^n using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 75 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/logn.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/logn.asm" push namespace core LN: ; Computes Ln(x) using ROM FP-CALC call __FPSTACK_PUSH @@ -191,7 +191,7 @@ LN: ; Computes Ln(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 76 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" push namespace core SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH @@ -201,7 +201,7 @@ SIN: ; Computes SIN using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 77 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sqrt.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sqrt.asm" push namespace core SQRT: ; Computes SQRT(x) using ROM FP-CALC call __FPSTACK_PUSH @@ -211,6 +211,16 @@ SQRT: ; Computes SQRT(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 78 "arch/zx48k/19.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 79 "arch/zx48k/19.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -239,15 +249,5 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 79 "arch/zx48k/19.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 80 "arch/zx48k/19.bas" END diff --git a/tests/functional/arch/zx48k/70.asm b/tests/functional/arch/zx48k/70.asm index d50abb70a..0eeac293f 100644 --- a/tests/functional/arch/zx48k/70.asm +++ b/tests/functional/arch/zx48k/70.asm @@ -57,66 +57,6 @@ _a: ei ret ;; --- end of user code --- -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/cos.asm" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" - ; ------------------------------------------------------------- - ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC - ; ------------------------------------------------------------- - push namespace core - __FPSTACK_PUSH EQU 2AB6h ; Stores an FP number into the ROM FP stack (A, ED CB) - __FPSTACK_POP EQU 2BF1h ; Pops an FP number out of the ROM FP stack (A, ED CB) -__FPSTACK_PUSH2: ; Pushes Current A ED CB registers and top of the stack on (SP + 4) - ; Second argument to push into the stack calculator is popped out of the stack - ; Since the caller routine also receives the parameters into the top of the stack - ; four bytes must be removed from SP before pop them out - call __FPSTACK_PUSH ; Pushes A ED CB into the FP-STACK - exx - pop hl ; Caller-Caller return addr - exx - pop hl ; Caller return addr - pop af - pop de - pop bc - push hl ; Caller return addr - exx - push hl ; Caller-Caller return addr - exx - jp __FPSTACK_PUSH -__FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK - ; This format is specified in the ZX 48K Manual - ; You can push a 16 bit signed integer as - ; 0 SS LL HH 0, being SS the sign and LL HH the low - ; and High byte respectively - ld a, h - rla ; sign to Carry - sbc a, a ; 0 if positive, FF if negative - ld e, a - ld d, l - ld c, h - xor a - ld b, a - jp __FPSTACK_PUSH - pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/cos.asm" - push namespace core -COS: ; Computes COS using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 20h ; COS - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 35 "arch/zx48k/70.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/exp.asm" - push namespace core -EXP: ; Computes e^n using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 26h ; E^n - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 36 "arch/zx48k/70.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/ftou32reg.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/neg32.asm" push namespace core @@ -215,8 +155,68 @@ __FTOU8: ; Converts float in C ED LH to Unsigned byte in A ld a, l ret pop namespace +#line 35 "arch/zx48k/70.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/cos.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" + ; ------------------------------------------------------------- + ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC + ; ------------------------------------------------------------- + push namespace core + __FPSTACK_PUSH EQU 2AB6h ; Stores an FP number into the ROM FP stack (A, ED CB) + __FPSTACK_POP EQU 2BF1h ; Pops an FP number out of the ROM FP stack (A, ED CB) +__FPSTACK_PUSH2: ; Pushes Current A ED CB registers and top of the stack on (SP + 4) + ; Second argument to push into the stack calculator is popped out of the stack + ; Since the caller routine also receives the parameters into the top of the stack + ; four bytes must be removed from SP before pop them out + call __FPSTACK_PUSH ; Pushes A ED CB into the FP-STACK + exx + pop hl ; Caller-Caller return addr + exx + pop hl ; Caller return addr + pop af + pop de + pop bc + push hl ; Caller return addr + exx + push hl ; Caller-Caller return addr + exx + jp __FPSTACK_PUSH +__FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK + ; This format is specified in the ZX 48K Manual + ; You can push a 16 bit signed integer as + ; 0 SS LL HH 0, being SS the sign and LL HH the low + ; and High byte respectively + ld a, h + rla ; sign to Carry + sbc a, a ; 0 if positive, FF if negative + ld e, a + ld d, l + ld c, h + xor a + ld b, a + jp __FPSTACK_PUSH + pop namespace +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/cos.asm" + push namespace core +COS: ; Computes COS using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 20h ; COS + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 36 "arch/zx48k/70.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/exp.asm" + push namespace core +EXP: ; Computes e^n using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 26h ; E^n + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace #line 37 "arch/zx48k/70.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/logn.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/logn.asm" push namespace core LN: ; Computes Ln(x) using ROM FP-CALC call __FPSTACK_PUSH @@ -226,7 +226,7 @@ LN: ; Computes Ln(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 38 "arch/zx48k/70.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" push namespace core SIN: ; Computes SIN using ROM FP-CALC call __FPSTACK_PUSH @@ -236,7 +236,7 @@ SIN: ; Computes SIN using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 39 "arch/zx48k/70.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sqrt.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sqrt.asm" push namespace core SQRT: ; Computes SQRT(x) using ROM FP-CALC call __FPSTACK_PUSH @@ -246,6 +246,16 @@ SQRT: ; Computes SQRT(x) using ROM FP-CALC jp __FPSTACK_POP pop namespace #line 40 "arch/zx48k/70.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 41 "arch/zx48k/70.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -274,16 +284,6 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 41 "arch/zx48k/70.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 42 "arch/zx48k/70.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/u32tofreg.asm" push namespace core diff --git a/tests/functional/arch/zx48k/read10.asm b/tests/functional/arch/zx48k/read10.asm index 6653493e0..cfae2c5a1 100644 --- a/tests/functional/arch/zx48k/read10.asm +++ b/tests/functional/arch/zx48k/read10.asm @@ -1060,7 +1060,7 @@ __REFRESH_TMP: ENDP pop namespace #line 116 "arch/zx48k/read10.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -1100,7 +1100,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 117 "arch/zx48k/read10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 118 "arch/zx48k/read10.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -1118,7 +1138,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 117 "arch/zx48k/read10.bas" +#line 119 "arch/zx48k/read10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/ploadf.asm" ; Parameter / Local var load ; A => Offset @@ -1159,7 +1179,7 @@ __PLOADF: add hl, de jp __LOADF pop namespace -#line 118 "arch/zx48k/read10.bas" +#line 120 "arch/zx48k/read10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -1185,7 +1205,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 119 "arch/zx48k/read10.bas" +#line 121 "arch/zx48k/read10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printf.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printstr.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" @@ -1527,7 +1547,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP pop namespace -#line 121 "arch/zx48k/read10.bas" +#line 123 "arch/zx48k/read10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pstoref.asm" ; Stores FP number in A ED CB at location HL+IX ; HL = Offset @@ -1573,7 +1593,7 @@ __PSTOREF: pop de jp __STOREF pop namespace -#line 122 "arch/zx48k/read10.bas" +#line 124 "arch/zx48k/read10.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -2333,25 +2353,5 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 123 "arch/zx48k/read10.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 124 "arch/zx48k/read10.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 125 "arch/zx48k/read10.bas" END diff --git a/tests/functional/arch/zx48k/read13.asm b/tests/functional/arch/zx48k/read13.asm index 1fe75d2e8..f8430f4ce 100644 --- a/tests/functional/arch/zx48k/read13.asm +++ b/tests/functional/arch/zx48k/read13.asm @@ -1391,7 +1391,7 @@ __ILOAD32: ret pop namespace #line 114 "arch/zx48k/read13.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -1431,7 +1431,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 115 "arch/zx48k/read13.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 116 "arch/zx48k/read13.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -1449,7 +1469,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 115 "arch/zx48k/read13.bas" +#line 117 "arch/zx48k/read13.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf16.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/_mul32.asm" ; Ripped from: http://www.andreadrian.de/oldcpu/z80_number_cruncher.html#moztocid784223 @@ -1545,7 +1565,7 @@ __ROUND_FIX: ; rounds a 64bit (32.32) fixed point number to 16.16 jp m, __NEG32 ; if negative, negates it ret pop namespace -#line 116 "arch/zx48k/read13.bas" +#line 118 "arch/zx48k/read13.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -1571,7 +1591,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 117 "arch/zx48k/read13.bas" +#line 119 "arch/zx48k/read13.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printf16.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printnum.asm" push namespace core @@ -1763,7 +1783,7 @@ __PRINT_FIX_LOOP: jp __PRINT_FIX_LOOP ENDP pop namespace -#line 119 "arch/zx48k/read13.bas" +#line 121 "arch/zx48k/read13.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -2666,17 +2686,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 120 "arch/zx48k/read13.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 121 "arch/zx48k/read13.bas" +#line 122 "arch/zx48k/read13.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/store32.asm" push namespace core __PISTORE32: @@ -2700,15 +2710,5 @@ __STORE32: ; Stores the given integer in DEBC at address HL ld (hl), d ret pop namespace -#line 122 "arch/zx48k/read13.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 123 "arch/zx48k/read13.bas" END diff --git a/tests/functional/arch/zx48k/read4.asm b/tests/functional/arch/zx48k/read4.asm index edd582dac..46e13b079 100644 --- a/tests/functional/arch/zx48k/read4.asm +++ b/tests/functional/arch/zx48k/read4.asm @@ -492,7 +492,7 @@ __LOADSTR: ; __FASTCALL__ entry ret pop namespace #line 89 "arch/zx48k/read4.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -532,7 +532,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 90 "arch/zx48k/read4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 91 "arch/zx48k/read4.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -550,7 +570,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 90 "arch/zx48k/read4.bas" +#line 92 "arch/zx48k/read4.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -576,7 +596,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 91 "arch/zx48k/read4.bas" +#line 93 "arch/zx48k/read4.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pushf.asm" ; Routine to push Float pointed by HL ; Into the stack. Notice that the hl points to the last @@ -604,7 +624,7 @@ __FP_PUSH_REV: exx ret pop namespace -#line 92 "arch/zx48k/read4.bas" +#line 94 "arch/zx48k/read4.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -1355,17 +1375,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 93 "arch/zx48k/read4.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 94 "arch/zx48k/read4.bas" +#line 95 "arch/zx48k/read4.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -1394,15 +1404,5 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 95 "arch/zx48k/read4.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 96 "arch/zx48k/read4.bas" END diff --git a/tests/functional/arch/zx48k/read5.asm b/tests/functional/arch/zx48k/read5.asm index 57c61d198..a45c7e0c8 100644 --- a/tests/functional/arch/zx48k/read5.asm +++ b/tests/functional/arch/zx48k/read5.asm @@ -1060,7 +1060,7 @@ __REFRESH_TMP: ENDP pop namespace #line 110 "arch/zx48k/read5.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -1100,7 +1100,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 111 "arch/zx48k/read5.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 112 "arch/zx48k/read5.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -1118,7 +1138,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 111 "arch/zx48k/read5.bas" +#line 113 "arch/zx48k/read5.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -1144,7 +1164,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 112 "arch/zx48k/read5.bas" +#line 114 "arch/zx48k/read5.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printf.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printstr.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" @@ -1486,7 +1506,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP pop namespace -#line 114 "arch/zx48k/read5.bas" +#line 116 "arch/zx48k/read5.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -2274,17 +2294,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 115 "arch/zx48k/read5.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 116 "arch/zx48k/read5.bas" +#line 117 "arch/zx48k/read5.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -2313,15 +2323,5 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 117 "arch/zx48k/read5.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 118 "arch/zx48k/read5.bas" END diff --git a/tests/functional/arch/zx48k/read8.asm b/tests/functional/arch/zx48k/read8.asm index cf308dd02..258ff5c06 100644 --- a/tests/functional/arch/zx48k/read8.asm +++ b/tests/functional/arch/zx48k/read8.asm @@ -1077,7 +1077,7 @@ __REFRESH_TMP: ENDP pop namespace #line 101 "arch/zx48k/read8.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -1117,7 +1117,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 102 "arch/zx48k/read8.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 103 "arch/zx48k/read8.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -1135,7 +1155,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 102 "arch/zx48k/read8.bas" +#line 104 "arch/zx48k/read8.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -1161,7 +1181,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 103 "arch/zx48k/read8.bas" +#line 105 "arch/zx48k/read8.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printf.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printstr.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" @@ -1503,7 +1523,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP pop namespace -#line 105 "arch/zx48k/read8.bas" +#line 107 "arch/zx48k/read8.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -2291,17 +2311,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 106 "arch/zx48k/read8.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 107 "arch/zx48k/read8.bas" +#line 108 "arch/zx48k/read8.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -2330,15 +2340,5 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 108 "arch/zx48k/read8.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 109 "arch/zx48k/read8.bas" END diff --git a/tests/functional/arch/zx48k/read9.asm b/tests/functional/arch/zx48k/read9.asm index 413ec28e0..4dbd6b410 100644 --- a/tests/functional/arch/zx48k/read9.asm +++ b/tests/functional/arch/zx48k/read9.asm @@ -1277,7 +1277,7 @@ __LOADF: ; Loads a 40 bits FP number from address pointed by HL ret pop namespace #line 118 "arch/zx48k/read9.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/stackf.asm" ; ------------------------------------------------------------- ; Functions to manage FP-Stack of the ZX Spectrum ROM CALC @@ -1317,7 +1317,27 @@ __FPSTACK_I16: ; Pushes 16 bits integer in HL into the FP ROM STACK ld b, a jp __FPSTACK_PUSH pop namespace -#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" +#line 2 "/zxbasic/src/lib/arch/zx48k/runtime/math/sin.asm" + push namespace core +SIN: ; Computes SIN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 1Fh + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 119 "arch/zx48k/read9.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/math/tan.asm" + push namespace core +TAN: ; Computes TAN using ROM FP-CALC + call __FPSTACK_PUSH + rst 28h ; ROM CALC + defb 21h ; TAN + defb 38h ; END CALC + jp __FPSTACK_POP + pop namespace +#line 120 "arch/zx48k/read9.bas" +#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/mulf.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) ; All of them uses A EDCB registers as 1st paramter. @@ -1335,7 +1355,7 @@ __MULF: ; Multiplication defb 38h; ; END CALC jp __FPSTACK_POP pop namespace -#line 119 "arch/zx48k/read9.bas" +#line 121 "arch/zx48k/read9.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/pow.asm" ; ------------------------------------------------------------- ; Floating point library using the FP ROM Calculator (ZX 48K) @@ -1361,7 +1381,7 @@ __POW: ; Exponentiation jp __FPSTACK_POP ENDP pop namespace -#line 120 "arch/zx48k/read9.bas" +#line 122 "arch/zx48k/read9.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printf.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/printstr.asm" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/free.asm" @@ -1703,7 +1723,7 @@ __PRINTF: ; Prints a Fixed point Number stored in C ED LH RECLAIM2 EQU 19E8h ENDP pop namespace -#line 122 "arch/zx48k/read9.bas" +#line 124 "arch/zx48k/read9.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/read_restore.asm" ;; This implements READ & RESTORE functions ;; Reads a new element from the DATA Address code @@ -2463,17 +2483,7 @@ __DATA_ADDR: ;; Stores current DATA ptr dw .DATA.__DATA__0 ENDP pop namespace -#line 123 "arch/zx48k/read9.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/sin.asm" - push namespace core -SIN: ; Computes SIN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 1Fh - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace -#line 124 "arch/zx48k/read9.bas" +#line 125 "arch/zx48k/read9.bas" #line 1 "/zxbasic/src/lib/arch/zx48k/runtime/storef.asm" push namespace core __PISTOREF: ; Indect Stores a float (A, E, D, C, B) at location stored in memory, pointed by (IX + HL) @@ -2502,15 +2512,5 @@ __STOREF: ; Stores the given FP number in A EDCB at address HL ld (hl), b ret pop namespace -#line 125 "arch/zx48k/read9.bas" -#line 1 "/zxbasic/src/lib/arch/zx48k/runtime/tan.asm" - push namespace core -TAN: ; Computes TAN using ROM FP-CALC - call __FPSTACK_PUSH - rst 28h ; ROM CALC - defb 21h ; TAN - defb 38h ; END CALC - jp __FPSTACK_POP - pop namespace #line 126 "arch/zx48k/read9.bas" END