diff --git a/blk/042 b/blk/042 index 862ebf3..45b0351 100644 --- a/blk/042 +++ b/blk/042 @@ -7,10 +7,10 @@ context, branching doesn't work. f IF A ELSE B THEN: if f is true, execute A, if false, execute B. ELSE is optional. +[IF] .. [THEN]: Meta-IF. Works outside definitions. No [ELSE]. BEGIN .. f UNTIL: if f is false, branch to BEGIN. BEGIN .. AGAIN: Always branch to BEGIN. 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 -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 -have to consume it to avoid PSP leak. (cont.) + + + (cont.) diff --git a/blk/043 b/blk/043 index 14cecc7..e4c6099 100644 --- a/blk/043 +++ b/blk/043 @@ -1,4 +1,8 @@ -(cont.) +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. x is dropped +in case of an OF match, *but it is kept if it reaches C*. You +have to consume it to avoid PSP leak. + (br) -- Branches by the number specified in the 2 following bytes. Can be negative. (?br) f -- Branch if f is false. @@ -9,8 +13,3 @@ ABORT -- Resets PS and RS and returns to interpreter. ABORT" x" -- *I* Compiles a ." followed by a ABORT. EXECUTE a -- Execute wordref at addr a -INTERPRET -- Get a line from stdin, compile it in tmp memory, - then execute the compiled contents. -LEAVE -- In a DO..LOOP, exit at the next LOOP call. -QUIT -- Return to interpreter prompt immediately -EXIT! -- Exit current INTERPRET loop. diff --git a/blk/044 b/blk/044 new file mode 100644 index 0000000..1ff3ef1 --- /dev/null +++ b/blk/044 @@ -0,0 +1,5 @@ +INTERPRET -- Get a line from stdin, compile it in tmp memory, + then execute the compiled contents. +LEAVE -- In a DO..LOOP, exit at the next LOOP call. +QUIT -- Return to interpreter prompt immediately +EXIT! -- Exit current INTERPRET loop. diff --git a/blk/426 b/blk/426 index 5d02510..c80b968 100644 --- a/blk/426 +++ b/blk/426 @@ -6,3 +6,7 @@ H@ 2- ( push a. -2 for allot offset ) ; IMMEDIATE +: [IF] + IF EXIT THEN + LIT< [THEN] BEGIN DUP WORD S= UNTIL DROP ; +: [THEN] ; diff --git a/emul/stage0.bin b/emul/stage0.bin index 25a33ae..c2c3b5d 100644 Binary files a/emul/stage0.bin and b/emul/stage0.bin differ