symbol -> bareword
This commit is contained in:
parent
c1a11c0522
commit
9bfc460499
75
bfloat16.tal
75
bfloat16.tal
|
@ -76,7 +76,7 @@
|
||||||
( #00 #86 #7f ;bf16-join JSR2 ;emit-bf16 JSR2 NEWLINE )
|
( #00 #86 #7f ;bf16-join JSR2 ;emit-bf16 JSR2 NEWLINE )
|
||||||
( #ff ;byte-to-bf16 JSR2 ;test JSR2 )
|
( #ff ;byte-to-bf16 JSR2 ;test JSR2 )
|
||||||
( #ff ;byte-to-bf16 JSR2 #01 ;round-shift JSR2 ;test JSR2
|
( #ff ;byte-to-bf16 JSR2 #01 ;round-shift JSR2 ;test JSR2
|
||||||
#03 ;byte-to-bf16 JSR2 ;test JSR2
|
#03 ;byte-to-bf16 JSR2 ;test JSR2 )
|
||||||
#7f80 ;test JSR2
|
#7f80 ;test JSR2
|
||||||
#ff80 ;test JSR2
|
#ff80 ;test JSR2
|
||||||
#ff81 ;test JSR2
|
#ff81 ;test JSR2
|
||||||
|
@ -87,12 +87,18 @@
|
||||||
#3f80 ;test JSR2
|
#3f80 ;test JSR2
|
||||||
#bf80 ;test JSR2
|
#bf80 ;test JSR2
|
||||||
#4000 ;test JSR2
|
#4000 ;test JSR2
|
||||||
#4080 ;test JSR2 )
|
#4080 ;test JSR2
|
||||||
#00 #00 DIV ( exit )
|
#4100 ;test JSR2
|
||||||
BRK
|
|
||||||
|
#3f80 ;test JSR2
|
||||||
|
#3f80 DUP2 ;add-bf16 JSR2 ;test JSR2
|
||||||
|
|
||||||
|
#010f DEO BRK
|
||||||
|
|
||||||
@test ( x* -> )
|
@test ( x* -> )
|
||||||
DUP2 ;emit-u16 JSR2 SPACE LIT '- EMIT LIT '> EMIT SPACE ;emit-bf16 JSR2 NEWLINE JMP2r
|
DUP2 ;emit-u16 JSR2 SPACE
|
||||||
|
LIT "- EMIT LIT "> EMIT SPACE
|
||||||
|
;emit-bf16 JSR2 NEWLINE JMP2r
|
||||||
|
|
||||||
@emit-digit ( d^ -> )
|
@emit-digit ( d^ -> )
|
||||||
DUP #0a LTH
|
DUP #0a LTH
|
||||||
|
@ -111,36 +117,36 @@
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@emit-s8 ( x^ -> )
|
@emit-s8 ( x^ -> )
|
||||||
DUP #07 SFT ,&is-negative JCN LIT '+ EMIT ;emit-u8 JSR2 JMP2r
|
DUP #07 SFT ,&is-negative JCN LIT "+ EMIT ;emit-u8 JSR2 JMP2r
|
||||||
&is-negative LIT '- EMIT #7f AND #80 SWP SUB ;emit-u8 JSR2 JMP2r
|
&is-negative LIT "- EMIT #7f AND #80 SWP SUB ;emit-u8 JSR2 JMP2r
|
||||||
|
|
||||||
@emit-s16 ( x* -> )
|
@emit-s16 ( x* -> )
|
||||||
DUP2 #0f SFT2 SWP POP ,&is-negative JCN LIT '+ EMIT ;emit-u16 JSR2 JMP2r
|
DUP2 #0f SFT2 SWP POP ,&is-negative JCN LIT "+ EMIT ;emit-u16 JSR2 JMP2r
|
||||||
&is-negative LIT '- EMIT #7fff AND2 #8000 SWP2 SUB2 ;emit-u16 JSR2 JMP2r
|
&is-negative LIT "- EMIT #7fff AND2 #8000 SWP2 SUB2 ;emit-u16 JSR2 JMP2r
|
||||||
|
|
||||||
@emit-bf16 ( x* -> )
|
@emit-bf16 ( x* -> )
|
||||||
;bf16-split JSR2 ( sgn exp mnt )
|
;bf16-split JSR2 ( sgn exp mnt )
|
||||||
|
|
||||||
( sentinel or value )
|
( sentinel or value )
|
||||||
OVR #ff NEQ ,&non-sentinal JCN
|
OVR #ff NEQ ,&non-sentinal JCN
|
||||||
,&is-nan JCN POP #00 EQU ,&pos-inf JCN LIT '- EMIT
|
,&is-nan JCN POP #00 EQU ,&pos-inf JCN LIT "- EMIT
|
||||||
&pos-inf LIT 'i EMIT LIT 'n EMIT LIT 'f EMIT JMP2r
|
&pos-inf LIT "i EMIT LIT "n EMIT LIT "f EMIT JMP2r
|
||||||
&is-nan LIT 'n EMIT LIT 'a EMIT LIT 'n EMIT JMP2r
|
&is-nan LIT "n EMIT LIT "a EMIT LIT "n EMIT JMP2r
|
||||||
|
|
||||||
( zero or non-zero )
|
( zero or non-zero )
|
||||||
&non-sentinal DUP2 ORA ,&non-zero JCN
|
&non-sentinal DUP2 ORA ,&non-zero JCN
|
||||||
POP2 ,&is-negative-zero JCN ,&zero-suffix JMP
|
POP2 ,&is-negative-zero JCN ,&zero-suffix JMP
|
||||||
&is-negative-zero LIT '- EMIT
|
&is-negative-zero LIT "- EMIT
|
||||||
&zero-suffix LIT '0 EMIT LIT 'x EMIT LIT '0 EMIT LIT '. EMIT
|
&zero-suffix LIT "0 EMIT LIT "x EMIT LIT "0 EMIT LIT ". EMIT
|
||||||
#00 ;emit-u8 JSR2 LIT 'p EMIT #00 ;emit-s8 JSR2 JMP2r
|
#00 ;emit-u8 JSR2 LIT "p EMIT #00 ;emit-s8 JSR2 JMP2r
|
||||||
|
|
||||||
( normal or subnormal )
|
( normal or subnormal )
|
||||||
&non-zero ROT ,&is-negative JCN ,&post-sgn JMP
|
&non-zero ROT ,&is-negative JCN ,&post-sgn JMP
|
||||||
&is-negative LIT '- EMIT
|
&is-negative LIT "- EMIT
|
||||||
&post-sgn LIT '0 EMIT LIT 'x EMIT
|
&post-sgn LIT "0 EMIT LIT "x EMIT
|
||||||
OVR ,&is-normal JCN LIT '0 ,&suffix JMP &is-normal LIT '1
|
OVR ,&is-normal JCN LIT "0 ,&suffix JMP &is-normal LIT "1
|
||||||
&suffix EMIT LIT '. EMIT ;emit-u8 JSR2
|
&suffix EMIT LIT ". EMIT ;emit-u8 JSR2
|
||||||
LIT 'p EMIT #7f SUB ;emit-s8 JSR2
|
LIT "p EMIT #7f SUB ;emit-s8 JSR2
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
@bf16-join ( sgn^ exp^ mta^ -> x* )
|
@bf16-join ( sgn^ exp^ mta^ -> x* )
|
||||||
|
@ -162,6 +168,8 @@
|
||||||
%EXPONENT { #10 SFT2 POP }
|
%EXPONENT { #10 SFT2 POP }
|
||||||
%MANTISSA { NIP #7f AND }
|
%MANTISSA { NIP #7f AND }
|
||||||
|
|
||||||
|
%MAX { GTHk JMP SWP POP }
|
||||||
|
|
||||||
( returns full mta: #00 to #ff )
|
( returns full mta: #00 to #ff )
|
||||||
( normal numbers will be >= #80 )
|
( normal numbers will be >= #80 )
|
||||||
( subnormal numbers will be < #80 )
|
( subnormal numbers will be < #80 )
|
||||||
|
@ -306,12 +314,25 @@
|
||||||
( 5. inf + x = inf )
|
( 5. inf + x = inf )
|
||||||
( 6. -inf + x = -inf )
|
( 6. -inf + x = -inf )
|
||||||
@add-bf16 ( x* y* -> z* )
|
@add-bf16 ( x* y* -> z* )
|
||||||
DUP2 ;is-nan JMP2 STH SWP2
|
DUP2 ;is-nan JSR2 STH SWP2 ( y x [ynan?] )
|
||||||
DUP2 ;is-nan JMP2 STH SWP2
|
DUP2 ;is-nan JSR2 STH SWP2 ( x y [xnan? ynan? ] )
|
||||||
STH2r ORA ,&nan JCN ( is lhs or rhs nan? )
|
STH2r ORA ,&nan JCN ( x y )
|
||||||
|
|
||||||
|
DUP2 ;is-inf JSR2 ,&y-inf JCN ( x y )
|
||||||
|
OVR2 ;is-inf JSR2 ,&x-inf JCN ( x y )
|
||||||
|
|
||||||
|
OVR2 OVR2 ( x y x y )
|
||||||
|
EXPONENT STH EXPONENT STHr ( x* y* ex^ ey^ )
|
||||||
|
EQUk ,&same-exponent JCN
|
||||||
|
LTHk ,&smaller-x JCN
|
||||||
|
SWP STH2 SWP2 STH2r
|
||||||
|
|
||||||
|
&smaller-x ( s* b* es^ eb^ )
|
||||||
|
STHk SWP SUB ( s* b* delta^ [eb] )
|
||||||
|
|
||||||
|
|
||||||
|
&same-epxponent ( x* y* ex^ ey^ )
|
||||||
|
|
||||||
DUP2 ;is-inf ,&rhs-inf JCN ( is rhs inf? )
|
|
||||||
SWP2 ;is-inf ,&lhs-inf JCN ( is lhs inf? )
|
|
||||||
|
|
||||||
( TODO: determine exponent, round, and add )
|
( TODO: determine exponent, round, and add )
|
||||||
( stack is [rhs lhs] but order doesn't matter )
|
( stack is [rhs lhs] but order doesn't matter )
|
||||||
|
@ -319,8 +340,8 @@
|
||||||
JMP2r
|
JMP2r
|
||||||
|
|
||||||
&nan POP2 POP2 #ffff JMP2r
|
&nan POP2 POP2 #ffff JMP2r
|
||||||
&rhs-inf SWP2 #8000 EOR2 EQUk ,&nan JCN POP2 JMP2r
|
&y-inf SWP2 #8000 EOR2 EQU2k ,&nan JCN POP2 JMP2r
|
||||||
&lhs-inf SWP2 POP2 JMP2r
|
&x-inf POP2 JMP2r
|
||||||
|
|
||||||
( TODO )
|
( TODO )
|
||||||
( lots of stuff including: )
|
( lots of stuff including: )
|
||||||
|
|
10
fix16.tal
10
fix16.tal
|
@ -219,6 +219,16 @@
|
||||||
@x16-remainder ( x* y* -> x%y* )
|
@x16-remainder ( x* y* -> x%y* )
|
||||||
DIV2k MUL2 SUB2 JMP2r
|
DIV2k MUL2 SUB2 JMP2r
|
||||||
|
|
||||||
|
@x16-from-s8 ( n^ -> x* )
|
||||||
|
#00 JMP2r
|
||||||
|
|
||||||
|
@x16-from-s16 ( n* -> x* )
|
||||||
|
DUP2 #ff80 GTH2 ,&neg JCN
|
||||||
|
DUP2 #007f GTH2 ,&error JCN
|
||||||
|
NIP #00 SWP JMP2r
|
||||||
|
&neg NIP #ff SWP JMP2r
|
||||||
|
&error #0000 DIV
|
||||||
|
|
||||||
( 1.5 -> 1, 0.5 -> 0, -1.5 -> -1 )
|
( 1.5 -> 1, 0.5 -> 0, -1.5 -> -1 )
|
||||||
@x16-to-s16 ( x* -> whole* )
|
@x16-to-s16 ( x* -> whole* )
|
||||||
DUP2 #7fff GTH2 ,&neg JCN ( x0 x1 )
|
DUP2 #7fff GTH2 ,&neg JCN ( x0 x1 )
|
||||||
|
|
Loading…
Reference in New Issue