mirror of
https://github.com/irmen/prog8.git
synced 2025-01-14 01:29:55 +00:00
fixed crash on cx16 in word to float conversion
This commit is contained in:
parent
69780ecde9
commit
6c8b18ddbd
@ -99,9 +99,9 @@ _flt65536 .byte 145,0,0,0,0 ; 65536.0
|
|||||||
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
asmsub GIVAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
||||||
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
|
; ---- signed 16 bit word in A/Y (lo/hi) to float in fac1
|
||||||
%asm {{
|
%asm {{
|
||||||
sta P8ZP_SCRATCH_W2
|
sta P8ZP_SCRATCH_B1
|
||||||
tya
|
tya
|
||||||
ldy P8ZP_SCRATCH_W2
|
ldy P8ZP_SCRATCH_B1
|
||||||
jmp GIVAYF ; this uses the inverse order, Y/A
|
jmp GIVAYF ; this uses the inverse order, Y/A
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -110,9 +110,9 @@ asmsub FTOSWRDAY () clobbers(X) -> uword @ AY {
|
|||||||
; ---- fac1 to signed word in A/Y
|
; ---- fac1 to signed word in A/Y
|
||||||
%asm {{
|
%asm {{
|
||||||
jsr FTOSWORDYA ; note the inverse Y/A order
|
jsr FTOSWORDYA ; note the inverse Y/A order
|
||||||
sta P8ZP_SCRATCH_REG
|
sta P8ZP_SCRATCH_B1
|
||||||
tya
|
tya
|
||||||
ldy P8ZP_SCRATCH_REG
|
ldy P8ZP_SCRATCH_B1
|
||||||
rts
|
rts
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,16 @@ main {
|
|||||||
sub start () {
|
sub start () {
|
||||||
|
|
||||||
word ww
|
word ww
|
||||||
float x_f = -300.0
|
|
||||||
float y_f
|
float y_f
|
||||||
|
float fl
|
||||||
for ww in -300 to 300 { ; TODO fix crash if ww is not defined
|
for ww in -300 to 300 { ; TODO fix crash if ww is not defined
|
||||||
;fl = ww as float ; TODO doesn't work???
|
fl = ww as float
|
||||||
y_f = cos(x_f/30.0)*60 - x_f/1.7
|
floats.print_f(fl)
|
||||||
; gfx2.plot(ww + 320 as uword, (y_f + 240) as uword, 1)
|
txt.chrout(' ')
|
||||||
x_f += 1.0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test_stack.test()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user