mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-23 16:08:06 +11:00
forth: Forth-ify "ABORT""
This commit is contained in:
parent
6487c713ef
commit
4627e1c977
@ -1,6 +1,7 @@
|
||||
: H HERE @ ;
|
||||
: -^ SWAP - ;
|
||||
: COMPILE ' LITN ['] , , ; IMMEDIATE
|
||||
: [COMPILE] ' , ; IMMEDIATE
|
||||
: BEGIN H ; IMMEDIATE
|
||||
: AGAIN COMPILE (bbr) H -^ C, ; IMMEDIATE
|
||||
: UNTIL COMPILE SKIP? COMPILE (bbr) H -^ C, ; IMMEDIATE
|
||||
@ -36,7 +37,6 @@
|
||||
H 1 - ( push a. -1 for allot offset )
|
||||
; IMMEDIATE
|
||||
|
||||
: ? @ . ;
|
||||
: VARIABLE CREATE 2 ALLOT ;
|
||||
: CONSTANT CREATE H ! DOES> @ ;
|
||||
: = CMP NOT ;
|
||||
@ -44,6 +44,7 @@
|
||||
: > CMP 1 = ;
|
||||
: / /MOD SWAP DROP ;
|
||||
: MOD /MOD DROP ;
|
||||
: ABORT" [COMPILE] ." COMPILE ABORT ; IMMEDIATE
|
||||
|
||||
( In addition to pushing H this compiles 2 >R so that loop variables are sent
|
||||
to PS at runtime )
|
||||
|
@ -44,7 +44,8 @@ directly, but as part of another word.
|
||||
ALLOT n -- Move HERE by n bytes
|
||||
C, b -- Write byte b in HERE and advance it.
|
||||
CREATE x -- Create cell named x. Doesn't allocate a PF.
|
||||
[COMPILE] x -- Compile word x and write it to HERE
|
||||
[COMPILE] x -- Compile word x and write it to HERE. IMMEDIATE
|
||||
words are *not* executed.
|
||||
COMPILE x -- Meta compiles. Kind of blows the mind. See below.
|
||||
CONSTANT x n -- Creates cell x that when called pushes its value
|
||||
DOES> -- See description at top of file
|
||||
|
@ -23,6 +23,8 @@
|
||||
AGAIN
|
||||
;
|
||||
|
||||
: ? @ . ;
|
||||
|
||||
: PUSHDGTS
|
||||
999 SWAP ( stop indicator )
|
||||
DUP 0 = IF '0' EXIT THEN ( 0 is a special case )
|
||||
|
@ -712,21 +712,9 @@ abortUnderflow:
|
||||
.dw PRINT
|
||||
.dw ABORT
|
||||
|
||||
.db "ABORT", '"'
|
||||
.fill 1
|
||||
.dw ABORT
|
||||
.db 1 ; IMMEDIATE
|
||||
ABORTI:
|
||||
.dw compiledWord
|
||||
.dw PRINTI
|
||||
.dw NUMBER
|
||||
.dw ABORT
|
||||
.dw WR
|
||||
.dw EXIT
|
||||
|
||||
.db "BYE"
|
||||
.fill 4
|
||||
.dw ABORTI
|
||||
.dw ABORT
|
||||
.db 0
|
||||
BYE:
|
||||
.dw nativeWord
|
||||
@ -871,42 +859,9 @@ EXECUTE:
|
||||
jp (hl) ; go!
|
||||
|
||||
|
||||
.db "[COMPIL"
|
||||
.dw EXECUTE
|
||||
.db 1 ; IMMEDIATE
|
||||
COMPILE:
|
||||
.dw compiledWord
|
||||
.dw WORD
|
||||
.dw FIND_
|
||||
.dw CSKIP
|
||||
.dw .maybeNum
|
||||
.dw DUP
|
||||
.dw ISIMMED
|
||||
.dw CSKIP
|
||||
.dw .word
|
||||
; is immediate. just execute.
|
||||
.dw EXECUTE
|
||||
.dw EXIT
|
||||
|
||||
.word:
|
||||
.dw compiledWord
|
||||
.dw WR
|
||||
.dw R2P ; exit COMPILE
|
||||
.dw DROP
|
||||
.dw EXIT
|
||||
|
||||
.maybeNum:
|
||||
.dw compiledWord
|
||||
.dw PARSEI
|
||||
.dw LITN
|
||||
.dw R2P ; exit COMPILE
|
||||
.dw DROP
|
||||
.dw EXIT
|
||||
|
||||
|
||||
.db ";"
|
||||
.fill 6
|
||||
.dw COMPILE
|
||||
.dw EXECUTE
|
||||
.db 1 ; IMMEDIATE
|
||||
ENDDEF:
|
||||
.dw compiledWord
|
||||
@ -931,11 +886,41 @@ DEFINE:
|
||||
.dw compiledWord
|
||||
.dw WR
|
||||
; BBR branch mark
|
||||
.dw COMPILE
|
||||
.dw .compile
|
||||
.dw BBR
|
||||
.db 4
|
||||
; no need for EXIT, ENDDEF takes care of taking us out
|
||||
|
||||
.compile:
|
||||
.dw compiledWord
|
||||
.dw WORD
|
||||
.dw FIND_
|
||||
.dw CSKIP
|
||||
.dw .maybeNum
|
||||
.dw DUP
|
||||
.dw ISIMMED
|
||||
.dw CSKIP
|
||||
.dw .word
|
||||
; is immediate. just execute.
|
||||
.dw EXECUTE
|
||||
.dw EXIT
|
||||
|
||||
.word:
|
||||
.dw compiledWord
|
||||
.dw WR
|
||||
.dw R2P ; exit .compile
|
||||
.dw DROP
|
||||
.dw EXIT
|
||||
|
||||
.maybeNum:
|
||||
.dw compiledWord
|
||||
.dw PARSEI
|
||||
.dw LITN
|
||||
.dw R2P ; exit .compile
|
||||
.dw DROP
|
||||
.dw EXIT
|
||||
|
||||
|
||||
|
||||
.db "DOES>"
|
||||
.fill 2
|
||||
|
Loading…
Reference in New Issue
Block a user