diff --git a/blk.fs b/blk.fs index 16a174f..5feba91 100644 --- a/blk.fs +++ b/blk.fs @@ -291,10 +291,11 @@ CREATE lblnext 0 , ( stable ABI until set in B300 ) ( ----- 026 ) ( Place BEGIN, where you want to jump back and AGAIN after a relative jump operator. Just like BSET and BWR. ) -: BEGIN, PC ; -: BSET PC SWAP ! ; +: BEGIN, + PC DUP 0x8000 AND IF ABORT" PC must be < 0x8000" THEN ; +: BSET BEGIN, SWAP ! ; ( same as BSET, but we need to write a placeholder ) -: FJR, PC 0 C, ; +: FJR, BEGIN, 0 C, ; : IFZ, JRNZ, FJR, ; : IFNZ, JRZ, FJR, ; : IFC, JRNC, FJR, ; diff --git a/doc/asm.txt b/doc/asm.txt index a20731a..06e0a5e 100644 --- a/doc/asm.txt +++ b/doc/asm.txt @@ -60,6 +60,9 @@ labels, write happen before set. The write operation writes a dummy placeholder, and then the set operation writes the offset at that placeholder's address. +Important limitation: Flow words are broken when PC reaches +0x8000. The BREAK, word relies on that 15th bit as a flag. + Variable actions are expected to be called with labels in front of them. Examples: