Selaa lähdekoodia

Add [IF] .. [THEN]

Will be useful as kinds of "#ifdef"s during xcomp.
pull/102/head
Virgil Dupras 4 vuotta sitten
vanhempi
commit
4501313410
5 muutettua tiedostoa jossa 18 lisäystä ja 10 poistoa
  1. +4
    -4
      blk/042
  2. +5
    -6
      blk/043
  3. +5
    -0
      blk/044
  4. +4
    -0
      blk/426
  5. BIN
      emul/stage0.bin

+ 4
- 4
blk/042 Näytä tiedosto

@@ -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.)

+ 5
- 6
blk/043 Näytä tiedosto

@@ -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.

+ 5
- 0
blk/044 Näytä tiedosto

@@ -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.

+ 4
- 0
blk/426 Näytä tiedosto

@@ -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] ;

BIN
emul/stage0.bin Näytä tiedosto


Loading…
Peruuta
Tallenna