added floats.push() and floats.pop()

fixed vm pop.f
This commit is contained in:
Irmen de Jong 2023-12-26 15:19:49 +01:00
parent 0d44492086
commit f948917124
4 changed files with 37 additions and 9 deletions

View File

@ -215,4 +215,17 @@ sub clampf(float value, float minimum, float maximum) -> float {
return minimum return minimum
} }
inline asmsub push(float value @FAC1) {
%asm {{
jsr floats.pushFAC1
}}
}
inline asmsub pop() -> float @FAC1 {
%asm {{
clc
jsr floats.popFAC
}}
}
} }

View File

@ -173,4 +173,19 @@ sub normalize(float value) -> float {
return value return value
} }
sub push(float value) {
%ir {{
loadm.f fr65535,floats.push.value
push.f fr65535
return
}}
}
sub pop() -> float {
%ir {{
pop.f fr65535
returnr.f fr65535
}}
}
} }

View File

@ -1,17 +1,17 @@
%import textio %import textio
;;%import floats %import floats
%zeropage basicsafe %zeropage basicsafe
main { main {
sub start() { sub start() {
sys.push(11) sys.push(11)
sys.pushw(2222) sys.pushw(2222)
;;floats.pushf(floats.π) floats.push(floats.π)
cx16.r2++ cx16.r2++
;;float pi = floats.popf() float pi = floats.pop()
;;floats.print_f(pi) floats.print_f(pi)
;;txt.nl() txt.nl()
cx16.r1 = sys.popw() cx16.r1 = sys.popw()
cx16.r0L = sys.pop() cx16.r0L = sys.pop()

View File

@ -2406,10 +2406,10 @@ internal fun Stack<UByte>.popf(): Double {
val bits = b7 + val bits = b7 +
(1L shl 8)*b6 + (1L shl 8)*b6 +
(1L shl 16)*b5 + (1L shl 16)*b5 +
(1L shl 24)*b4 (1L shl 24)*b4 +
(1L shl 32)*b3 (1L shl 32)*b3 +
(1L shl 40)*b2 (1L shl 40)*b2 +
(1L shl 48)*b1 (1L shl 48)*b1 +
(1L shl 56)*b0 (1L shl 56)*b0
return Double.fromBits(bits) return Double.fromBits(bits)
} }