1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 09:08:06 +11:00

z80a: add ELSE,

This commit is contained in:
Virgil Dupras 2020-12-07 23:06:12 -05:00
parent 45eceaaf61
commit 74f46c1288
2 changed files with 9 additions and 5 deletions

7
blk.fs
View File

@ -300,11 +300,10 @@ CREATE lblnext 0 , ( stable ABI until set in B300 )
: IFC, JRNC, FJR, ; : IFC, JRNC, FJR, ;
: IFNC, JRC, FJR, ; : IFNC, JRC, FJR, ;
: THEN, : THEN,
DUP PC ( l l pc ) DUP PC ( l l pc ) -^ 1- ( l off )
-^ 1- ( l off )
( warning: l is a PC offset, not a mem addr! ) ( warning: l is a PC offset, not a mem addr! )
SWAP ORG @ + BIN( @ - ( off addr ) SWAP ORG @ + BIN( @ - ( off addr ) C! ;
C! ; : ELSE, JR, FJR, SWAP THEN, ;
( ----- 027 ) ( ----- 027 )
: FWR BSET 0 C, ; : FWR BSET 0 C, ;
: FSET @ THEN, ; : FSET @ THEN, ;

View File

@ -87,6 +87,11 @@ the opposite condition is met, a relative jump is made to
THEN,'s PC. For example, if you have IFZ, a jump is made when THEN,'s PC. For example, if you have IFZ, a jump is made when
Z is unset. Z is unset.
There can be an ELSE, in the middle of an IF, and THEN,. When
present, IF, jumps to it when the condition is unmet. When the
condition is met, upon reaching the ELSE, we unconditionally
jump to the THEN,.
On the BEGIN,..AGAIN, side, it's a bit different. You start On the BEGIN,..AGAIN, side, it's a bit different. You start
with your BEGIN, instruction, and then later you issue a with your BEGIN, instruction, and then later you issue a
JRxx, instr followed by AGAIN,. Exactly like you would do JRxx, instr followed by AGAIN,. Exactly like you would do
@ -96,7 +101,7 @@ On top of that, you have the very nice BREAK, instruction,
which must also be preceded by a JRxx, and will jump to the which must also be preceded by a JRxx, and will jump to the
PC following the next AGAIN,. Examples: PC following the next AGAIN,. Examples:
IFZ, NOP, THEN, IFZ, NOP, ELSE, NOP, THEN,
BEGIN, NOP, JR, AGAIN, ( unconditional ) BEGIN, NOP, JR, AGAIN, ( unconditional )
BEGIN, NOP, JRZ, AGAIN, ( conditional ) BEGIN, NOP, JRZ, AGAIN, ( conditional )
BEGIN, NOP, JRZ, BREAK, JR, AGAIN, ( break off the loop ) BEGIN, NOP, JRZ, BREAK, JR, AGAIN, ( break off the loop )