diff --git a/compiler/res/prog8lib/c64/floats.asm b/compiler/res/prog8lib/c64/floats.asm index 940b89567..164742c7f 100644 --- a/compiler/res/prog8lib/c64/floats.asm +++ b/compiler/res/prog8lib/c64/floats.asm @@ -356,17 +356,17 @@ mul_f .proc neg_f .proc ; -- toggle the sign bit on the stack - lda P8ESTACK_LO+3,x + lda P8ESTACK_HI+3,x eor #$80 - sta P8ESTACK_LO+3,x + sta P8ESTACK_HI+3,x rts .pend abs_f .proc ; -- strip the sign bit on the stack - lda P8ESTACK_LO+3,x + lda P8ESTACK_HI+3,x and #$7f - sta P8ESTACK_LO+3,x + sta P8ESTACK_HI+3,x rts .pend diff --git a/compiler/res/prog8lib/c64/floats.p8 b/compiler/res/prog8lib/c64/floats.p8 index c42fd813f..3e1de1fed 100644 --- a/compiler/res/prog8lib/c64/floats.p8 +++ b/compiler/res/prog8lib/c64/floats.p8 @@ -207,8 +207,8 @@ sub print_f (float value) { jsr c64.CHROUT iny bne - - ldx floats_store_reg -+ rts ++ ldx floats_store_reg + rts }} } diff --git a/examples/test.p8 b/examples/test.p8 index 9f41bdf56..9521e7344 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -13,62 +13,94 @@ main { ; uword[] colors = [ c1, c2, c3] ; TODO should contain pointers to (the first element) of each struct - str[] names = ["aap", "noot", "mies", "vuur"] - uword[] names3 = ["aap", "noot", "mies", "vuur"] - ubyte[] values = [11,22,33,44] - uword[] arrays = [names, names3, values] +; str[] names = ["aap", "noot", "mies", "vuur"] +; uword[] names3 = ["aap", "noot", "mies", "vuur"] +; ubyte[] values = [11,22,33,44] +; uword[] arrays = [names, names3, values] + asmsub testX() { + %asm {{ + stx _saveX + lda #13 + jsr txt.chrout + lda _saveX + jsr txt.print_ub + lda #13 + jsr txt.chrout + ldx _saveX + rts +_saveX .byte 0 + }} + } + sub start() { - byte bb = 100 - word ww = 30000 +; byte bb = 100 +; word ww = 30000 float ff1 = 12345 float ff2 = -99999 ;ff = 1+((-ff) *3) ; TODO fix invalid splitting (can't split because it references ff itself) ;ff = 1+((-ff2) *3) ; TODO splitting should be okay here + testX() floats.print_f(ff1) ; TODO if we remove this, the following calcuation is wrong + testX() txt.chrout('\n') + testX() ff1 = -ff2 * 3 + testX() + floats.print_f(ff1) + testX() + txt.chrout('\n') + testX() + + ff1 = -ff1 * 3 + testX() + floats.print_f(ff1) + testX() + txt.chrout('\n') + + ff1 = abs(ff2) floats.print_f(ff1) txt.chrout('\n') + testX() return - struct Color { - ubyte red - ubyte green - ubyte blue - } - - ;Color c1 = [11,22,33] ; TODO fix struct initializer crash - Color c1 - Color c2 - Color c3 - ;Color c2 = [11,22,33] - ;Color c3 = [11,22,33] - ;uword[] colors = [ c1, c2, c3] ; TODO should contain pointers to (the first element) of each struct - - c1 = c2 - ;c1 = [11,22,33] ; TODO rewrite into individual struct member assignments - - - uword s - for s in names { - txt.print(s) - txt.chrout('\n') - } - txt.chrout('\n') - - txt.print(names[2]) - txt.chrout('\n') - txt.print(names[3]) - txt.chrout('\n') - - repeat { - txt.print(names3[rnd()&3]) - txt.chrout(' ') - } +; struct Color { +; ubyte red +; ubyte green +; ubyte blue +; } +; +; ;Color c1 = [11,22,33] ; TODO fix struct initializer crash +; Color c1 +; Color c2 +; Color c3 +; ;Color c2 = [11,22,33] +; ;Color c3 = [11,22,33] +; ;uword[] colors = [ c1, c2, c3] ; TODO should contain pointers to (the first element) of each struct +; +; c1 = c2 +; ;c1 = [11,22,33] ; TODO rewrite into individual struct member assignments +; +; +; uword s +; for s in names { +; txt.print(s) +; txt.chrout('\n') +; } +; txt.chrout('\n') +; +; txt.print(names[2]) +; txt.chrout('\n') +; txt.print(names[3]) +; txt.chrout('\n') +; +; repeat { +; txt.print(names3[rnd()&3]) +; txt.chrout(' ') +; } } }