mirror of
https://github.com/irmen/prog8.git
synced 2024-10-19 22:24:17 +00:00
fix ubyte/uword to float conversion crashes on Commander X16
This commit is contained in:
parent
60e169bd87
commit
9120e1de88
@ -79,10 +79,10 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
|||||||
; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1
|
; ---- unsigned 16 bit word in A/Y (lo/hi) to fac1
|
||||||
%asm {{
|
%asm {{
|
||||||
phx
|
phx
|
||||||
sta P8ZP_SCRATCH_W2
|
sta _tmp
|
||||||
sty P8ZP_SCRATCH_B1
|
sty P8ZP_SCRATCH_B1
|
||||||
tya
|
tya
|
||||||
ldy P8ZP_SCRATCH_W2
|
ldy _tmp
|
||||||
jsr GIVAYF ; load it as signed... correct afterwards
|
jsr GIVAYF ; load it as signed... correct afterwards
|
||||||
lda P8ZP_SCRATCH_B1
|
lda P8ZP_SCRATCH_B1
|
||||||
bpl +
|
bpl +
|
||||||
@ -91,6 +91,7 @@ asmsub GIVUAYFAY (uword value @ AY) clobbers(A,X,Y) {
|
|||||||
jsr FADD
|
jsr FADD
|
||||||
+ plx
|
+ plx
|
||||||
rts
|
rts
|
||||||
|
_tmp .byte 0
|
||||||
_flt65536 .byte 145,0,0,0,0 ; 65536.0
|
_flt65536 .byte 145,0,0,0,0 ; 65536.0
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
@ -128,6 +129,14 @@ asmsub GETADRAY () clobbers(X) -> uword @ AY {
|
|||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
asmsub FREADUY (ubyte value @Y) {
|
||||||
|
; -- 8 bit unsigned Y -> float in fac1
|
||||||
|
%asm {{
|
||||||
|
lda #0
|
||||||
|
jmp GIVAYF
|
||||||
|
}}
|
||||||
|
}
|
||||||
|
|
||||||
sub print_f (float value) {
|
sub print_f (float value) {
|
||||||
; ---- prints the floating point value (without a newline).
|
; ---- prints the floating point value (without a newline).
|
||||||
%asm {{
|
%asm {{
|
||||||
|
@ -3,67 +3,37 @@
|
|||||||
%import test_stack
|
%import test_stack
|
||||||
%zeropage dontuse
|
%zeropage dontuse
|
||||||
|
|
||||||
; TODO fix float conversion crashes on Cx16 (ubyte as float, uword as float)
|
|
||||||
|
|
||||||
main {
|
main {
|
||||||
sub start() {
|
sub start() {
|
||||||
uword total=0
|
|
||||||
uword xx
|
uword xx
|
||||||
float fl
|
float fl
|
||||||
float fltotal=0.0
|
float fltotal=0.0
|
||||||
ubyte ub = 22
|
ubyte ub = 22
|
||||||
|
|
||||||
for xx in 0 to 100 {
|
ub = 22
|
||||||
txt.print_uw(xx*xx)
|
fl = ub as float
|
||||||
txt.chrout(',')
|
floats.print_f(fl)
|
||||||
}
|
txt.nl()
|
||||||
|
ub = 255
|
||||||
|
fl = ub as float
|
||||||
|
floats.print_f(fl)
|
||||||
|
txt.nl()
|
||||||
|
xx = 123
|
||||||
|
fl = xx as float
|
||||||
|
floats.print_f(fl)
|
||||||
|
txt.nl()
|
||||||
|
xx = 55555
|
||||||
|
fl = xx as float
|
||||||
|
floats.print_f(fl)
|
||||||
txt.nl()
|
txt.nl()
|
||||||
|
|
||||||
total = 0
|
fltotal=0.0
|
||||||
c64.SETTIM(0,0,0)
|
|
||||||
repeat 5 {
|
|
||||||
for xx in 1 to 255 {
|
for xx in 1 to 255 {
|
||||||
total += xx*xx
|
fl = xx as float
|
||||||
|
fltotal = fl * fl
|
||||||
}
|
}
|
||||||
}
|
|
||||||
txt.print_uw(total)
|
|
||||||
txt.nl()
|
|
||||||
txt.print_uw(c64.RDTIM16())
|
|
||||||
txt.nl()
|
|
||||||
txt.nl()
|
|
||||||
test_stack.test()
|
test_stack.test()
|
||||||
|
|
||||||
; fltotal=0.0
|
|
||||||
; c64.SETTIM(0,0,0)
|
|
||||||
; repeat 5 {
|
|
||||||
; for xx in 1 to 255 {
|
|
||||||
; fl = xx as float
|
|
||||||
; ; fl = ub as float
|
|
||||||
; fltotal = fl * fl
|
|
||||||
; }
|
|
||||||
; }
|
|
||||||
;
|
|
||||||
; floats.print_f(fltotal)
|
|
||||||
; txt.nl()
|
|
||||||
; txt.print_uw(c64.RDTIM16())
|
|
||||||
; txt.nl()
|
|
||||||
; txt.nl()
|
|
||||||
;
|
|
||||||
; fltotal=0.0
|
|
||||||
; c64.SETTIM(0,0,0)
|
|
||||||
; repeat 5 {
|
|
||||||
; for xx in 1 to 255 {
|
|
||||||
; fl = xx as float
|
|
||||||
; ; fl = ub as float
|
|
||||||
; fltotal = fl ** 2
|
|
||||||
; }
|
|
||||||
; }
|
|
||||||
;
|
|
||||||
; floats.print_f(fltotal)
|
|
||||||
; txt.nl()
|
|
||||||
; txt.print_uw(c64.RDTIM16())
|
|
||||||
; txt.nl()
|
|
||||||
; txt.nl()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user