Repository navigation
Full Changelog: v3.2.1...v3.3.0
antforth v3.3.0
Twelve new words, stack-underflow checks on every word that takes arguments,
and fixes for banked memory. Tested on real MicroBeast hardware.
New words
Stack
NIP ( a b -- b ),TUCK ( a b -- b a b )(Core Extensions)-ROT ( a b c -- c a b ), the reverse ofROT(antforth extension)? ( addr -- )prints the value stored at an address, the same as@ .(Tools)
Comparisons
<>,0<>,0>,U>(Core Extensions)<=,>=, signed (antforth extensions)
Loops
BEGIN … AGAINfor loops that never end on their own, such as task bodies
and event loops. Leave withEXIT.?DOruns zero times when the limit equals the start (DOwould run 65,536
times). It works withLOOP,+LOOP,LEAVE,UNLOOP,IandJ.
Core Extensions coverage goes from 15 to 23 of the 46 words.
Stack underflow is caught everywhere
Every kernel word and assembler mnemonic that takes stack arguments now raises
-4 stack underflow when they're missing. The check runs before the word
changes anything. Before, DUP, 0=, 1+, TYPE, FILL, MOVE,
ACTIVATE and about 45 others silently worked on whatever was left in a
register.
PICKandROLLcheck that the stack holdsuitems.SET-ORDERandRESTORE-INPUTcount their arguments correctly.- An assembler instruction missing an operand raises
-4before it writes any
code bytes, so a caught error leavesHEREwhere it was.
Fixes
>NUMBERswapped the two halves of its starting value. With a nonzero
start,1 0 S" 0" >NUMBER 2DROP D.printed655360instead of10.
Starting from0 0, as most code does, wasn't affected.- Banked words could hide or hang kernel words. Giving
+BANKthe same
physical page twice made two banks share one piece of RAM, so defining words
in one bank overwrote dictionary entries in the other. A lookup could then
missCRorBANK!, or hang.+BANKnow refuses a page that is already
listed (dup?,error -2), and so does the boot page list. - Parsing near the top of a bank could write into fixed RAM. When a bank
above 0 was nearly full, the parse buffer andPADran past$C000and
overwrote bank 0's dictionary. Banks above 0 now end at$BF58, so.BANKS
shows 16,216 bytes free per bank instead of 16,384. WORDrefuses words over 128 characters witherror -18, so even
EVALUATEcan't overflow the parse buffer.
Things to know when upgrading
- Room for only two tasks. Every task's control block (TCB) must sit below
$8000, and this kernel leaves room for two named tasks
(TASK CONSTANT name), with 25 bytes to spare. A thirdTASKraises-8.
Create your tasks before anything else.TRAFFIC.FTHnow does this, so
LIGHTSis task 1. To see the free room, typeDECIMAL 32768 HERE - .at a
fresh prompt. See "How many tasks fit" indocs/phase6-multitasker.md. - Scripts that add the same page twice (
$22 +BANK $22 +BANK) now fail.
Use a different page for each bank. - The underflow checks cost some speed:
INCLUDEis about 10–14% slower in
CPU cycles. Disk I/O is unchanged, so the real-world difference is smaller. - Banked code must leave 168 bytes below
$C000. Code that filled a bank to
the brim before now raises-8sooner.
Size
antforth.com is 31,395 bytes, 641 more than v3.2.1.