32-bit fixed point, base 1000
This commit is contained in:
parent
5551e6c695
commit
e2d4e0506e
|
@ -0,0 +1,68 @@
|
||||||
|
( fix32.tal )
|
||||||
|
|
||||||
|
%POP4 { POP2 POP2 }
|
||||||
|
%POP8 { POP2 POP2 POP2 POP2 }
|
||||||
|
%DENOM16 { #03e8 }
|
||||||
|
%DENOM32 { #0000 #03e8 }
|
||||||
|
|
||||||
|
@x32-eq ( x/** y/** -> bool^ ) !eq32
|
||||||
|
@x32-ne ( x/** y/** -> bool^ ) !ne32
|
||||||
|
|
||||||
|
@x32-is-zero ( x/** -> bool^ ) !is-zero32
|
||||||
|
@x32-non-zero ( x/** -> bool^ ) !non-zero32
|
||||||
|
@x32-is-positive ( x/** -> bool^ ) POP2 #8000 LTH2 JMP2r
|
||||||
|
@x32-is-negative ( x/** -> bool^ ) POP2 #7fff GTH2 JMP2r
|
||||||
|
|
||||||
|
@x32-from-u8 ( x^ -> x/** )
|
||||||
|
#0000 ROT OVR SWP DENOM32 !mul32
|
||||||
|
|
||||||
|
@x32-from-u16 ( x* -> x/** )
|
||||||
|
#0000 SWP2 DENOM32 !mul32
|
||||||
|
|
||||||
|
@x32-from-u32 ( x** -> x/** )
|
||||||
|
DENOM32 !mul32
|
||||||
|
|
||||||
|
@x32-prepare-cmp ( x/** y/** -> x/** y/** xp^ yp^ )
|
||||||
|
OVR2 #8000 LTH2 ,&yp STR STH2 STH2
|
||||||
|
OVR2 #8000 LTH2 ,&xp STR STH2r STH2r
|
||||||
|
LIT2 [ &xp $1 &yp $1 ] JMP2r
|
||||||
|
|
||||||
|
@x32-lt ( x/** y/** -> bool^ )
|
||||||
|
x32-prepare-cmp NEQk ?{ POP2 !lt32 } LTH STH POP8 STHr JMP2r
|
||||||
|
|
||||||
|
@x32-gt ( x/** y/** -> bool^ )
|
||||||
|
x32-prepare-cmp NEQk ?{ POP2 !gt32 } GTH STH POP8 STHr JMP2r
|
||||||
|
|
||||||
|
@x32-lteq ( x/** y/** -> bool^ )
|
||||||
|
x32-prepare-cmp NEQk ?{ POP2 !lteq32 } LTH STH POP8 STHr JMP2r
|
||||||
|
|
||||||
|
@x32-gteq ( x/** y/** -> bool^ )
|
||||||
|
x32-prepare-cmp NEQk ?{ POP2 !gteq32 } GTH STH POP8 STHr JMP2r
|
||||||
|
|
||||||
|
@x32-add ( x/** y/** -> z/** )
|
||||||
|
!add32
|
||||||
|
|
||||||
|
@x32-sub ( x/** y/** -> z/** )
|
||||||
|
!sub32
|
||||||
|
|
||||||
|
@x32-negate ( x/** y/** -> z/** )
|
||||||
|
!negate32
|
||||||
|
|
||||||
|
( multiply a fixed point number by an unsigned integer )
|
||||||
|
@x32-scaled-mul32 ( x/** y** -> z/** )
|
||||||
|
!mul32
|
||||||
|
|
||||||
|
( multiply a fixed point number by an unsigned integer )
|
||||||
|
@x32-scaled-mul16 ( x/** y* -> z/** )
|
||||||
|
!mul16
|
||||||
|
|
||||||
|
@x32-scaled-div32 ( x/** y** -> z/** )
|
||||||
|
!div32
|
||||||
|
|
||||||
|
( TODO )
|
||||||
|
@x32-mul ( x/** y/** -> z/** )
|
||||||
|
|
||||||
|
( TODO )
|
||||||
|
@x32-div ( x/** y/** -> z/** )
|
||||||
|
|
||||||
|
~math32.tal
|
Loading…
Reference in New Issue