From 123473dfc8bb0b2878a02b0a3694078501cfd204 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Tue, 6 Apr 2021 00:15:43 +0200 Subject: [PATCH] cleanup --- compiler/res/prog8lib/c64/floats.p8 | 2 +- compiler/res/prog8lib/cx16/floats.p8 | 3 +-- compiler/src/prog8/compiler/Compiler.kt | 2 +- docs/source/todo.rst | 2 -- examples/test.p8 | 28 ++++++++++++++----------- 5 files changed, 19 insertions(+), 18 deletions(-) diff --git a/compiler/res/prog8lib/c64/floats.p8 b/compiler/res/prog8lib/c64/floats.p8 index 729147d7f..10a730353 100644 --- a/compiler/res/prog8lib/c64/floats.p8 +++ b/compiler/res/prog8lib/c64/floats.p8 @@ -83,7 +83,7 @@ romsub $bc58 = ABS() ; fac1 = ABS(fac1) romsub $bf71 = SQR() clobbers(A,X,Y) ; fac1 = SQRT(fac1) romsub $bf74 = SQRA() clobbers(A,X,Y) ; fac1 = SQRT(fac2) romsub $bfed = EXP() clobbers(A,X,Y) ; fac1 = EXP(fac1) (e ** fac1) -romsub $bfb4 = NEGOP() clobbers(A) ; switch the sign of fac1 +romsub $bfb4 = NEGOP() clobbers(A) ; switch the sign of fac1 (fac1 = -fac1) romsub $e097 = RND() clobbers(A,X,Y) ; fac1 = RND(fac1) float random number generator romsub $e264 = COS() clobbers(A,X,Y) ; fac1 = COS(fac1) romsub $e26b = SIN() clobbers(A,X,Y) ; fac1 = SIN(fac1) diff --git a/compiler/res/prog8lib/cx16/floats.p8 b/compiler/res/prog8lib/cx16/floats.p8 index 8fd286a4b..437cee85b 100644 --- a/compiler/res/prog8lib/cx16/floats.p8 +++ b/compiler/res/prog8lib/cx16/floats.p8 @@ -42,7 +42,6 @@ romsub $fe12 = FADD(uword mflpt @ AY) clobbers(A,X,Y) ; fac1 += mflpt valu romsub $fe15 = FADDT() clobbers(A,X,Y) ; fac1 += fac2 romsub $fe1b = ZEROFC() clobbers(A,X,Y) ; fac1 = 0 romsub $fe1e = NORMAL() clobbers(A,X,Y) ; normalize fac1 (?) -romsub $fe21 = NEGFAC() clobbers(A,X,Y) ; fac1 = -fac1 romsub $fe24 = LOG() clobbers(A,X,Y) ; fac1 = LN(fac1) (natural log) romsub $fe27 = FMULT(uword mflpt @ AY) clobbers(A,X,Y) ; fac1 *= mflpt value from A/Y romsub $fe2a = FMULTT() clobbers(A,X,Y) ; fac1 *= fac2 @@ -67,7 +66,7 @@ romsub $fe78 = FINLOG(byte value @A) clobbers (A, X, Y) ; fac1 += sign romsub $fe7b = FOUT() clobbers(X) -> uword @ AY ; fac1 -> string, address returned in AY romsub $fe81 = SQR() clobbers(A,X,Y) ; fac1 = SQRT(fac1) romsub $fe84 = FPWRT() clobbers(A,X,Y) ; fac1 = fac2 ** fac1 -romsub $fe8a = NEGOP() clobbers(A,X,Y) ; fac1 = -fac1-1 +romsub $fe8a = NEGOP() clobbers(A) ; switch the sign of fac1 (fac1 = -fac1) romsub $fe8d = EXP() clobbers(A,X,Y) ; fac1 = EXP(fac1) (e ** fac1) romsub $fe96 = RND() clobbers(A,X,Y) ; fac1 = RND(fac1) float random number generator romsub $fe99 = COS() clobbers(A,X,Y) ; fac1 = COS(fac1) diff --git a/compiler/src/prog8/compiler/Compiler.kt b/compiler/src/prog8/compiler/Compiler.kt index b94bc6ea3..6cc517b61 100644 --- a/compiler/src/prog8/compiler/Compiler.kt +++ b/compiler/src/prog8/compiler/Compiler.kt @@ -214,7 +214,7 @@ private fun determineCompilationOptions(program: Program, compTarget: ICompilati } if (zpType==ZeropageType.FLOATSAFE && compTarget.name == Cx16Target.name) { - System.err.println("Warning: cx16 target must use zp option basicsafe instead of floatsafe") + System.err.println("Warning: zp option floatsafe changed to basicsafe for cx16 target") zpType = ZeropageType.BASICSAFE } diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 8abbb2f05..80b226d18 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,8 +2,6 @@ TODO ==== -- check use of float NEGOP vs NEGFAC for cx16 - - allow inlining of subroutines with params - optimize several inner loops in gfx2 - hoist all variable declarations up to the subroutine scope *before* even the constant folding takes place (to avoid undefined symbol errors when referring to a variable from another nested scope in the subroutine) diff --git a/examples/test.p8 b/examples/test.p8 index 3996a203c..84bd9f798 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -5,26 +5,30 @@ main { sub start() { - ;cx16.rombank(4) float f1 = 9.9999 float f2 = 8.8888 float f3 = 0.1111 - f3=cos(f3) + uword fs - floats.print_f(f1) - txt.nl() - floats.print_f(f2) - txt.nl() - floats.print_f(f3) - txt.nl() - f3 = cos(f3) - floats.print_f(f3) + %asm {{ + phx + lda #f1 + jsr floats.MOVFM + jsr floats.NEGOP + jsr floats.FOUT + sta fs + sty fs+1 + plx + }} - ;cx16.rombank(0) + txt.print_uwhex(fs,1) + txt.nl() + txt.print(fs) + txt.nl() txt.print("ok!\n") - sys.wait(2*60) } }