mirror of
https://github.com/irmen/prog8.git
synced 2024-12-27 05:29:38 +00:00
fix floats.parse_f() to use new kernal routine address for VAL
gives error message if it detects issues f.ex. with new kernal version that moves the routine
This commit is contained in:
parent
ae2d96c455
commit
ee4da1a757
@ -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
|
||||
}}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 ....
|
||||
|
||||
...
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user