mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 23:18:05 +11:00
forth: Forth-ify "."
This commit is contained in:
parent
839d7097e7
commit
017a469d9c
@ -49,3 +49,27 @@
|
|||||||
: > CMP 1 = ;
|
: > CMP 1 = ;
|
||||||
: / /MOD SWAP DROP ;
|
: / /MOD SWAP DROP ;
|
||||||
: MOD /MOD DROP ;
|
: MOD /MOD DROP ;
|
||||||
|
|
||||||
|
( Format decimals )
|
||||||
|
( TODO FORGET this word )
|
||||||
|
: PUSHDGTS
|
||||||
|
999 SWAP ( stop indicator )
|
||||||
|
DUP 0 = IF '0' EXIT THEN ( 0 is a special case )
|
||||||
|
BEGIN
|
||||||
|
DUP 0 = IF DROP EXIT THEN
|
||||||
|
10 /MOD ( r q )
|
||||||
|
SWAP '0' + SWAP ( d q )
|
||||||
|
AGAIN
|
||||||
|
;
|
||||||
|
|
||||||
|
: . ( n -- )
|
||||||
|
( handle negative )
|
||||||
|
( that "0 1 -" thing is because we don't parse negative
|
||||||
|
number correctly yet. )
|
||||||
|
DUP 0 < IF '-' EMIT 0 1 - * THEN
|
||||||
|
PUSHDGTS
|
||||||
|
BEGIN
|
||||||
|
DUP '9' > IF DROP EXIT THEN ( stop indicator, we're done )
|
||||||
|
EMIT
|
||||||
|
AGAIN
|
||||||
|
;
|
||||||
|
@ -476,26 +476,10 @@ INP:
|
|||||||
.dw sysvarWord
|
.dw sysvarWord
|
||||||
.dw INPUTPOS
|
.dw INPUTPOS
|
||||||
|
|
||||||
; ( n -- )
|
|
||||||
.db "."
|
|
||||||
.fill 6
|
|
||||||
.dw INP
|
|
||||||
.db 0
|
|
||||||
DOT:
|
|
||||||
.dw nativeWord
|
|
||||||
pop de
|
|
||||||
; We check PS explicitly because it doesn't look nice to spew gibberish
|
|
||||||
; before aborting the stack underflow.
|
|
||||||
call chkPSRS
|
|
||||||
call pad
|
|
||||||
call fmtDecimalS
|
|
||||||
call printstr
|
|
||||||
jp next
|
|
||||||
|
|
||||||
; ( n a -- )
|
; ( n a -- )
|
||||||
.db "!"
|
.db "!"
|
||||||
.fill 6
|
.fill 6
|
||||||
.dw DOT
|
.dw INP
|
||||||
.db 0
|
.db 0
|
||||||
STORE:
|
STORE:
|
||||||
.dw nativeWord
|
.dw nativeWord
|
||||||
|
@ -5,7 +5,6 @@ jp forthMain
|
|||||||
.inc "lib/util.asm"
|
.inc "lib/util.asm"
|
||||||
.inc "lib/parse.asm"
|
.inc "lib/parse.asm"
|
||||||
.inc "lib/ari.asm"
|
.inc "lib/ari.asm"
|
||||||
.inc "lib/fmt.asm"
|
|
||||||
.equ FORTH_RAMSTART RAMSTART
|
.equ FORTH_RAMSTART RAMSTART
|
||||||
.inc "forth/main.asm"
|
.inc "forth/main.asm"
|
||||||
.inc "forth/util.asm"
|
.inc "forth/util.asm"
|
||||||
|
@ -215,12 +215,12 @@ HLPointsUNWORD:
|
|||||||
pop hl
|
pop hl
|
||||||
ret
|
ret
|
||||||
|
|
||||||
; Checks flags Z and C and sets BC to 0 if Z, 1 if C and -1 otherwise
|
; Checks flags Z and S and sets BC to 0 if Z, 1 if C and -1 otherwise
|
||||||
flagsToBC:
|
flagsToBC:
|
||||||
ld bc, 0
|
ld bc, 0
|
||||||
ret z ; equal
|
ret z ; equal
|
||||||
inc bc
|
inc bc
|
||||||
ret c ; >
|
ret m ; >
|
||||||
; <
|
; <
|
||||||
dec bc
|
dec bc
|
||||||
dec bc
|
dec bc
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
.inc "lib/util.asm"
|
.inc "lib/util.asm"
|
||||||
.inc "lib/parse.asm"
|
.inc "lib/parse.asm"
|
||||||
.inc "lib/ari.asm"
|
.inc "lib/ari.asm"
|
||||||
.inc "lib/fmt.asm"
|
|
||||||
.equ FORTH_RAMSTART STDIO_RAMEND
|
.equ FORTH_RAMSTART STDIO_RAMEND
|
||||||
.inc "forth/main.asm"
|
.inc "forth/main.asm"
|
||||||
.inc "forth/util.asm"
|
.inc "forth/util.asm"
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
.inc "lib/util.asm"
|
.inc "lib/util.asm"
|
||||||
.inc "lib/parse.asm"
|
.inc "lib/parse.asm"
|
||||||
.inc "lib/ari.asm"
|
.inc "lib/ari.asm"
|
||||||
.inc "lib/fmt.asm"
|
|
||||||
.equ FORTH_RAMSTART STDIO_RAMEND
|
.equ FORTH_RAMSTART STDIO_RAMEND
|
||||||
.inc "forth/main.asm"
|
.inc "forth/main.asm"
|
||||||
.inc "forth/util.asm"
|
.inc "forth/util.asm"
|
||||||
|
Loading…
Reference in New Issue
Block a user