parent
3b66aefcd1
commit
f605e2d85c
14
blk/042
14
blk/042
@ -1,9 +1,9 @@
|
|||||||
Flow
|
Flow
|
||||||
|
|
||||||
Note about flow words: flow words can only be used in
|
Note that flow words can only be used in definitions. In the
|
||||||
definitions. In the INTERPRET loop, they don't have the desired
|
INTERPRET loop, they don't have the desired effect because each
|
||||||
effect because each word from the input stream is executed
|
word from the input stream is executed immediately. In this
|
||||||
immediately. In this context, branching doesn't work.
|
context, branching doesn't work.
|
||||||
|
|
||||||
f IF A ELSE B THEN: if f is true, execute A, if false, execute
|
f IF A ELSE B THEN: if f is true, execute A, if false, execute
|
||||||
B. ELSE is optional.
|
B. ELSE is optional.
|
||||||
@ -11,6 +11,6 @@ BEGIN .. f UNTIL: if f is false, branch to BEGIN.
|
|||||||
BEGIN .. AGAIN: Always branch to BEGIN.
|
BEGIN .. AGAIN: Always branch to BEGIN.
|
||||||
x y DO .. LOOP: LOOP increments y. if y != x, branch to DO.
|
x y DO .. LOOP: LOOP increments y. if y != x, branch to DO.
|
||||||
x CASE y OF A ENDOF z OF B ENDOF C ENDCASE: If x == y, execute
|
x CASE y OF A ENDOF z OF B ENDOF C ENDCASE: If x == y, execute
|
||||||
A, if x == z, execute B. Otherwise, execute C.
|
A, if x == z, execute B. Otherwise, execute C. x is dropped
|
||||||
|
in case of an OF match, *but it is kept if it reaches C*. You
|
||||||
(cont.)
|
have to consume it to avoid PSP leak. (cont.)
|
||||||
|
6
blk/427
6
blk/427
@ -1,10 +1,10 @@
|
|||||||
( During a CASE, the stack grows by 1 at each ENDOF so that
|
( During a CASE, the stack grows by 1 at each ENDOF so that
|
||||||
we can fill all those ENDOF branching addrs. So that we
|
we can fill all those ENDOF branching addrs. So that we
|
||||||
know when to stop, we put a 0 on PSP. That's our stopgap. )
|
know when to stop, we put a 0 on PSP. That's our stopgap. )
|
||||||
: CASE 0 COMPILE >R ; IMMEDIATE
|
: CASE 0 ; IMMEDIATE
|
||||||
: OF
|
: OF
|
||||||
COMPILE I COMPILE =
|
COMPILE OVER COMPILE =
|
||||||
[COMPILE] IF
|
[COMPILE] IF COMPILE DROP
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
: ENDOF [COMPILE] ELSE ; IMMEDIATE
|
: ENDOF [COMPILE] ELSE ; IMMEDIATE
|
||||||
|
|
||||||
|
6
blk/428
6
blk/428
@ -1,11 +1,9 @@
|
|||||||
( At this point, we have something like "0 e1 e2 e3 val". We
|
( At this point, we have something like "0 e1 e2 e3 val". We
|
||||||
want top drop val, and then call THEN as long as we don't
|
want to drop val, and then call THEN as long as we don't
|
||||||
hit 0. )
|
hit 0. )
|
||||||
: ENDCASE
|
: ENDCASE
|
||||||
BEGIN
|
BEGIN
|
||||||
DUP NOT IF
|
DUP NOT IF DROP EXIT THEN
|
||||||
DROP COMPILE R> COMPILE DROP EXIT
|
|
||||||
THEN
|
|
||||||
[COMPILE] THEN
|
[COMPILE] THEN
|
||||||
AGAIN
|
AGAIN
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
BIN
emul/stage0.bin
BIN
emul/stage0.bin
Binary file not shown.
@ -3,11 +3,12 @@
|
|||||||
'X' OF 42 ENDOF
|
'X' OF 42 ENDOF
|
||||||
0x12 OF 43 ENDOF
|
0x12 OF 43 ENDOF
|
||||||
255 OF 44 ENDOF
|
255 OF 44 ENDOF
|
||||||
45
|
1+
|
||||||
ENDCASE
|
ENDCASE
|
||||||
;
|
;
|
||||||
|
|
||||||
'X' foo 42 #eq
|
'X' foo 42 #eq
|
||||||
0x12 foo 43 #eq
|
0x12 foo 43 #eq
|
||||||
255 foo 44 #eq
|
255 foo 44 #eq
|
||||||
254 foo 45 #eq
|
254 foo 255 #eq
|
||||||
|
'S S0 #eq
|
||||||
|
Loading…
Reference in New Issue
Block a user