mirror of
https://github.com/irmen/prog8.git
synced 2025-01-08 22:32:06 +00:00
added floats.push() and floats.pop()
fixed vm pop.f
This commit is contained in:
parent
0d44492086
commit
f948917124
@ -215,4 +215,17 @@ sub clampf(float value, float minimum, float maximum) -> float {
|
||||
return minimum
|
||||
}
|
||||
|
||||
inline asmsub push(float value @FAC1) {
|
||||
%asm {{
|
||||
jsr floats.pushFAC1
|
||||
}}
|
||||
}
|
||||
|
||||
inline asmsub pop() -> float @FAC1 {
|
||||
%asm {{
|
||||
clc
|
||||
jsr floats.popFAC
|
||||
}}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -173,4 +173,19 @@ sub normalize(float value) -> float {
|
||||
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
|
||||
}}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,17 +1,17 @@
|
||||
%import textio
|
||||
;;%import floats
|
||||
%import floats
|
||||
%zeropage basicsafe
|
||||
|
||||
main {
|
||||
sub start() {
|
||||
sys.push(11)
|
||||
sys.pushw(2222)
|
||||
;;floats.pushf(floats.π)
|
||||
floats.push(floats.π)
|
||||
cx16.r2++
|
||||
|
||||
;;float pi = floats.popf()
|
||||
;;floats.print_f(pi)
|
||||
;;txt.nl()
|
||||
float pi = floats.pop()
|
||||
floats.print_f(pi)
|
||||
txt.nl()
|
||||
|
||||
cx16.r1 = sys.popw()
|
||||
cx16.r0L = sys.pop()
|
||||
|
@ -2406,10 +2406,10 @@ internal fun Stack<UByte>.popf(): Double {
|
||||
val bits = b7 +
|
||||
(1L shl 8)*b6 +
|
||||
(1L shl 16)*b5 +
|
||||
(1L shl 24)*b4
|
||||
(1L shl 32)*b3
|
||||
(1L shl 40)*b2
|
||||
(1L shl 48)*b1
|
||||
(1L shl 24)*b4 +
|
||||
(1L shl 32)*b3 +
|
||||
(1L shl 40)*b2 +
|
||||
(1L shl 48)*b1 +
|
||||
(1L shl 56)*b0
|
||||
return Double.fromBits(bits)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user