From b759d5e06a31656b31cfd68a3b4e758c6d8863d1 Mon Sep 17 00:00:00 2001 From: Irmen de Jong Date: Sun, 11 Oct 2020 17:45:40 +0200 Subject: [PATCH] fixed X register corruption on Cx16 verions of float.GIVUAYFAY and GIVAYFAY --- compiler/res/prog8lib/cx16/floats.p8 | 8 ++-- examples/mandelbrot-gfx.p8 | 1 - examples/test.p8 | 65 ++++++---------------------- 3 files changed, 18 insertions(+), 56 deletions(-) diff --git a/compiler/res/prog8lib/cx16/floats.p8 b/compiler/res/prog8lib/cx16/floats.p8 index ed7696dbb..716a30b5e 100644 --- a/compiler/res/prog8lib/cx16/floats.p8 +++ b/compiler/res/prog8lib/cx16/floats.p8 @@ -78,10 +78,10 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) { ; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1 %asm {{ phx - sta P8ZP_SCRATCH_REG + sta P8ZP_SCRATCH_W2 sty P8ZP_SCRATCH_B1 tya - ldy P8ZP_SCRATCH_REG + ldy P8ZP_SCRATCH_W2 jsr GIVAYF ; load it as signed... correct afterwards lda P8ZP_SCRATCH_B1 bpl + @@ -98,9 +98,9 @@ _flt65536 .byte 145,0,0,0,0 ; 65536.0 asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) { ; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1 %asm {{ - sta P8ZP_SCRATCH_REG + sta P8ZP_SCRATCH_W2 tya - ldy P8ZP_SCRATCH_REG + ldy P8ZP_SCRATCH_W2 jmp GIVAYF ; this uses the inverse order, Y/A }} } diff --git a/examples/mandelbrot-gfx.p8 b/examples/mandelbrot-gfx.p8 index f1196bc94..27a88e49a 100644 --- a/examples/mandelbrot-gfx.p8 +++ b/examples/mandelbrot-gfx.p8 @@ -39,7 +39,6 @@ main { iter++ } - ; TODO something above is causing a strange black column on the right on Cx16. if iter & 1 graphics.plot(pixelx, pixely) } diff --git a/examples/test.p8 b/examples/test.p8 index d166df350..5f4956a75 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -1,5 +1,6 @@ %import textio %import syslib +%import floats %zeropage basicsafe @@ -7,62 +8,24 @@ main { sub start() { - ubyte xx - ubyte yy - regx(xx) + str name = "irmen de jong" + uword strptr = &name -; str name = "irmen de jong" -; uword strptr = &name -; -; -; txt.print_ub(strlen("1234")) -; txt.chrout('\n') -; txt.print_ub(strlen(name)) -; txt.chrout('\n') -; txt.print_uwhex(strptr, 1) -; txt.chrout('\n') -; txt.print(strptr) -; txt.chrout('\n') -; txt.print_ub(strlen(strptr)) -; txt.chrout('\n') + + txt.print_ub(strlen("1234")) + txt.chrout('\n') + txt.print_ub(strlen(name)) + txt.chrout('\n') + txt.print_uwhex(strptr, 1) + txt.chrout('\n') + txt.print(strptr) + txt.chrout('\n') + txt.print_ub(strlen(strptr)) + txt.chrout('\n') } - asmsub regx(uword value @AX) { - %asm {{ - - nop - rts - }} - } - - asmsub print_10s(uword value @AY) clobbers(A, X, Y) { - %asm {{ - jsr conv.uword2decimal - lda conv.uword2decimal.decTenThousands - cmp #'0' - beq + - jsr c64.CHROUT -+ lda conv.uword2decimal.decThousands - cmp #'0' - beq + - jsr c64.CHROUT -+ lda conv.uword2decimal.decHundreds - cmp #'0' - beq + - jsr c64.CHROUT -+ lda conv.uword2decimal.decTens - jsr c64.CHROUT - lda #'.' - jsr c64.CHROUT - lda conv.uword2decimal.decOnes - jsr c64.CHROUT - rts - }} - } - - asmsub testX() { %asm {{ stx _saveX