mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-27 03:48:06 +11:00
a348ee9106
The few extra bytes they save in the core aren't worth the extra complexity. This was initially done in a context where I had troubles keeping the RC2014 binary with SDC inside the 8K limit. At this point, even with the few extra bytes we add here, we're at 7200 bytes, so I'd say we're fine.
15 lines
423 B
Plaintext
15 lines
423 B
Plaintext
( r c -- r f )
|
|
( Parse digit c and accumulate into result r.
|
|
Flag f is 0 when c was a valid digit, 1 when c was WS,
|
|
-1 when c was an invalid digit. )
|
|
: _pdacc
|
|
DUP 0x21 < IF DROP 1 EXIT THEN
|
|
( parse char )
|
|
( if bad, return "r -1" )
|
|
'0' -
|
|
DUP 10 < NOT IF DROP -1 EXIT THEN
|
|
( good, add to running result )
|
|
SWAP 10 * + ( r*10+n )
|
|
0 ( good )
|
|
;
|