From 63d2c973868908b4b1d9639f29969f13da3162f5 Mon Sep 17 00:00:00 2001 From: Virgil Dupras Date: Mon, 14 Dec 2020 14:40:22 -0500 Subject: [PATCH] z80 asm: document the 0x8000 limitation better When I get bitten by it myself, it's because it's clearly underdocumented! --- blk.fs | 7 ++++--- doc/asm.txt | 3 +++ 2 files changed, 7 insertions(+), 3 deletions(-) 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: