diff --git a/compiler/res/prog8lib/cx16/floats.p8 b/compiler/res/prog8lib/cx16/floats.p8 index d63ab9512..142ce1016 100644 --- a/compiler/res/prog8lib/cx16/floats.p8 +++ b/compiler/res/prog8lib/cx16/floats.p8 @@ -139,13 +139,27 @@ asmsub FREADUY (ubyte value @Y) { asmsub parse_f(str value @AY) -> float @FAC1 { ; -- parse a string value of a number to float in FAC1 ; warning: uses an internal BASIC routine that may be rom version dependent - ; ($ddf2 is inside the routine for VAL at $ddef) + ; ($deb6 is inside the routine for VAL at $deb3) See basic.sym from x16-rom + ; If at any time in the future the official VAL_1() routine from the kernal starts working, we should use that instead! %asm {{ sta $a9 sty $aa jsr prog8_lib.strlen + lda $deb6 + cmp #$d0 ; sanity check for kernal routine correct + bne + ; tya - jmp $ddf2 + jmp $deb6 ; kernal version dependent :( ++ ; print error message if routine is borked in kernal, and exit program + ldy #0 +- lda _msg,y + beq + + jsr cbm.CHROUT + iny + bne - ++ jmp sys.exit + +_msg .text 13,"?val kaputt",13,0 }} } diff --git a/compiler/res/prog8lib/cx16/syslib.p8 b/compiler/res/prog8lib/cx16/syslib.p8 index 052b75398..0e915a485 100644 --- a/compiler/res/prog8lib/cx16/syslib.p8 +++ b/compiler/res/prog8lib/cx16/syslib.p8 @@ -1458,7 +1458,7 @@ save_SCRATCH_ZPWORD2 .word 0 }} } - inline asmsub exit(ubyte returnvalue @A) { + asmsub exit(ubyte returnvalue @A) { ; -- immediately exit the program with a return code in the A register %asm {{ jsr cbm.CLRCHN ; reset i/o channels diff --git a/docs/source/todo.rst b/docs/source/todo.rst index 6b7a485ec..3e13a8890 100644 --- a/docs/source/todo.rst +++ b/docs/source/todo.rst @@ -2,10 +2,6 @@ TODO ==== -- fix floats.parse_f - did the routine move in kernal rom? - VAL at $ddef. Looks like it's now $deb3 (see basic.sym from x16-rom) - so assuming its internals hasen't changed you need to change the $ddf2 to $deb6? - - [on branch: shortcircuit] investigate McCarthy evaluation again? this may also reduce code size perhaps for things like if a>4 or a<2 .... ... diff --git a/examples/test.p8 b/examples/test.p8 index 132d8a4af..d9516542f 100644 --- a/examples/test.p8 +++ b/examples/test.p8 @@ -4,39 +4,12 @@ main { sub start() { - ubyte[100] storage = 0 - - txt.print("sizeof float = ") - txt.print_ub(sizeof(0.0)) - txt.print("\nsizeof word = ") - txt.print_ub(sizeof($0000)) - txt.print("\nsizeof byte = ") - txt.print_ub(sizeof($00)) - txt.print("\nsizeof bool = ") - txt.print_ub(sizeof(true)) + txt.print("enter number: ") + str buffer = "???????????????????????????" + void txt.input_chars(buffer) + float value = floats.parse_f(buffer) txt.nl() - - poke(&storage+10, 123) - pokew(&storage+11, 54321) - txt.print_ub(peek(&storage+10)) - txt.spc() - txt.print_uw(peekw(&storage+11)) - txt.nl() - - pokef(&storage+10, 3.14) - pokef($4000, 123.456) - floats.print_f(peekf(&storage+10)) - txt.nl() - floats.print_f(peekf($4000)) - txt.nl() - pokef(&storage+10, 3.1415927) - floats.print_f(peekf(&storage+10)) - txt.nl() - - for cx16.r2L in 0 to 20 { - txt.print_ubhex(storage[cx16.r2L], false) - txt.spc() - } + floats.print_f(value) txt.nl() } }