Tachyon compiles temporary code at the end of the code dictionary while words are stored end to end in the word dictionary while variables occupy data space. So code definitions can cascade into the next and names can be removed selectively while you can ERASE all variables and buffers in the data area without impacting code or dictionary.
As for LEAVE all it does is adjust the index to the limit so that it leaves on the next loop. (come to think of it I could just adjust the limit instead and still access the index after it leaves the loop). The separate loop stack will never interfere with code addresses stored on the return stack which otherwise would not crash gently (recoverable). Not an option on fail-soft software.
Console output testing LEAVE, disjointed DO I LOOP, code vs word dictionary vs data space.
Code:
TAQOZ# $80 $20 DO I EMIT I 'D' = IF LEAVE THEN LOOP --- !"#$%&'()*+,-./0123456789:;<=>?@ABCD ok
TAQOZ# : IEMIT I EMIT LOOP ; --- ok
TAQOZ# $80 $20 DO IEMIT --- !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ok
TAQOZ# ' IEMIT .L --- $0000_5BAA ok
TAQOZ# NFA' IEMIT .L --- $0000_DFA3 ok
TAQOZ# 4 longs samples --- ok
TAQOZ# 32 bytes inbuf --- ok
TAQOZ# samples 48 erase --- ok
TAQOZ# samples 48 DUMP ---
0001_2343: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................'
0001_2353: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................'
0001_2363: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 '................' ok
BTW, Since tables are used so often I have a special word that can preallocate space if needed or just tack on data. Being a table it resides in code space.
Here is a table of 16 byte values using the more unobtrusive and readable | instead of the C, (still use , for 32-bit longs)
Code:
0 TABLE ma 0 | 1 | 5 | 10 | 25 | 35 | 60 | 100 | 1 | 5 | 10 | 25 | 35 | 45 | 80 | 200 |
TAQOZ# ma 16 DUMP ---
05BC0: 00 01 05 0A 19 23 3C 64 01 05 0A 19 23 2D 50 C8 '.....#<d....#-P.' ok
But sometimes I define a forgettable helper stub to build a table in which case I just preallocate.
Code:
100 7 * TABLE FONT5X7
TACHYON does not try to be ANS compatible which might be fine for PCs but the embedded world needs far more flexibility.
Default base is always decimal with % # $ prefix to force binary, decimal, hex. The # in the prompt is the current decimal base.
EDIT: After posting this I revisited my kernel code and streamlined it a bit more. Now FOR NEXT and DO LOOP etc use the same stack structure so they can even be intermixed. FOR NEXT seems a bit redundant now since DO LOOP runs just as fast but FOR is equivalent to a 0 DO which means a FOR NEXT loop supports an incrementing I index. A loop takes 32 cycles or 107ns @300MHz.
Code:
TAQOZ# 1,000,000 LAP FOR NEXT LAP .LAP --- 32,000,096 cycles= 106,666,986ns @300MHz ok
TAQOZ# 1,000,000 0 LAP DO LOOP LAP .LAP --- 32,000,105 cycles= 106,667,016ns @300MHz ok
It will be interesting to see how I implement that on the 65816.