3 \ ... if/unless ... [else ...] then
6 ['] 0BRANCH , \ compile 0BRANCH
7 HERE \ save location of the offset on the stack
8 0 , \ compile a dummy offset
12 ['] NOT , \ compile NOT (to reverse the test)
13 [COMPILE] IF \ continue by calling the normal IF
18 HERE SWAP - \ calculate the offset from the address saved on the stack
19 SWAP ! \ store the offset in the back-filled location
23 ['] BRANCH , \ definite branch to just over the false-part
24 HERE \ save location of the offset on the stack
25 0 , \ compile a dummy offset
26 SWAP \ now back-fill the original (IF) offset
27 DUP \ same as for THEN word above
33 \ begin ... while ... repeat, begin ... until, begin ... repeat
36 HERE \ save location on the stack
40 ['] 0BRANCH , \ compile 0BRANCH
41 HERE - \ calculate the offset from the address saved on the stack
42 , \ compile the offset here
46 ['] BRANCH , \ compile BRANCH
47 HERE - \ calculate the offset back
48 , \ compile the offset here
52 ['] 0BRANCH , \ compile 0BRANCH
53 HERE \ save location of the offset2 on the stack
54 0 , \ compile a dummy offset2
58 ['] BRANCH , \ compile BRANCH
59 SWAP \ get the original offset (from BEGIN)
60 HERE - , \ and compile it after BRANCH
62 HERE SWAP - \ calculate the offset2
63 SWAP ! \ and back-fill it in the original location
70 ['] LIT , -1 , [COMPILE] IF
72 ['] LIT , HERE 0 , ['] >R ,
77 ['] 2DUP , ['] - , [COMPILE] IF
79 ['] LIT , HERE 0 , ['] >R ,
91 ['] R> , ['] RDROP , ['] RDROP ,
92 ['] LIT , HERE 7 + , ['] DUP , ['] -ROT , ['] - , ['] SWAP , ['] ! ,
102 \ Clean up return stack
104 ['] RDROP , ['] RDROP , ['] RDROP ,
109 ['] DUP , \ Store copy of increment
111 ['] R> , ['] SWAP , ['] R> , ['] SWAP , ['] R> , ['] SWAP , ['] + , ['] 2DUP , ['] - ,
112 ['] SWAP , ['] >R , ['] SWAP , ['] >R , ['] SWAP , ['] >R ,
114 \ Condition differently depending on sign of increment
115 ['] SWAP , ['] 0>= , [COMPILE] IF
121 \ Branch back to begining of loop kernel
122 ['] 0BRANCH , HERE - ,
125 ['] RDROP , ['] RDROP , ['] RDROP ,
127 \ Record address of loop end for any LEAVEs to use
131 ['] 2DROP , \ Clean up if loop was entirely skipped (?DO)
141 \ case [of ... endof]+ ... endcase
144 0 \ push 0 to mark the bottom of the stack
148 ['] OVER , \ compile OVER
150 [COMPILE] IF \ compile IF
151 ['] DROP , \ compile DROP
155 [COMPILE] ELSE \ ENDOF is the same as ELSE
159 ['] DROP , \ compile DROP
161 \ keep compiling THEN until we get to our zero marker