parsing wip

This commit is contained in:
~d6 2025-02-20 21:36:31 -05:00
parent 9c3cdc0575
commit bc43728ebf
1 changed files with 50 additions and 0 deletions

View File

@ -232,4 +232,54 @@
#01 SUB DUP ?&uloop ( x-1^ [...] )
POP JMP2r ( )
( returns nan [8000 0000] on error )
@x32-parse ( s* -> x/** )
( negate leading - ; ignore leading + )
LDAk LIT "- NEQ ?{ INC2 x32-parse !x32-negate }
LDAk LIT "+ NEQ ?{ INC2 !x32-parse }
( accumulate on rst ; reverse shorts )
LIT2r 0000 LIT2r 0000 ( pos* [lo* hi*] )
( trim leading zeros )
&trim LDAk LIT "0 NEQ ?&whole INC2 !&trim
( accumulate whole part )
&whole ( pos* [lo* hi*] )
LDAk #00 EQU ?&whole-done ( pos* [lo* hi*] )
LDAk #2e EQU ?&dot ( pos* [lo* hi*] )
LDAk #30 LTH ?&error1 ( pos* [lo* hi*] )
LDAk #39 GTH ?&error1 ( pos* [lo* hi*] )
#30 SUB #00 SWP #0000 SWP2 ( pos* 0* digit* [lo *hi*] )
STH2r STH2r u32-add STH2 STH2 ( pos* [lo2* hi2*] )
INC2 !&whole ( pos+1* [lo2* hi2*] )
&whole-done ( pos* [lo* hi*] )
POP2 STH2r STH2r !x32-from-u32 ( res/** )
&dot ( pos* [wlo* whi*] )
DUP2 LIT2r 0000 LIT2r 0000 ( orig* pos* [wlo* whi* slo* shi*] )
&fraction ( orig* pos* [wlo* whi* slo* shi*] )
LDAk #00 EQU ?&dot-done ( orig* pos* [wlo* whi* slo* shi*] )
LDAk #30 LTH ?&error2 ( orig* pos* [wlo* whi* slo* shi*] )
LDAk #39 GTH ?&error2 ( orig* pos* [wlo* whi* slo* shi*] )
#30 SUB #00 SWP #0000 SWP2 ( orig* pos* 0* digit* [wlo* whi* slo* shi*] )
STH2r STH2r u32-add STH2 STH2 ( orig* pos* [wlo* whi* slo2* shi2*] )
INC2 !&fraction ( pos+1* [wlo* whi* slo2* shi2*] )
&dot-done ( orig* pos* [wlo* whi* slo* shi*] )
SWP2 SUB2 ( count* [wlo* whi* slo* shi*] )
DUP2 #0003 LTH2 ?&dot-inc ( count* [wlo* whi* slo* shi*] )
DUP2 #0003 GTH2 ?&dot-dec ( count* [wlo* whi* slo* shi*] )
&dot-equ ( [wlo* whi* slo* shi*] )
POP2 STH2r STH2r STH2r STH2r ( s/** w** )
x32-from-u32 !x32-add ( x/** )
&dot-inc
ORA2k #0000 EQU2 ?&dot-equ
STH2r STH2r x32-ten x32-mul
STH2 STH2 #ffff ADD2 !dot-inc
&dot-dec
( TODO: div? really??? )
&error2 POP2r POP2r POP2
&error1 POP2r POP2r POP2 #8000 #0000 JMP2r
~math32.tal