Loading...
 
About the vocab stack.

vstack

SAM7 Emforth now has a vocabulary stack, not all forths do.
It is possible to have a single dictionary(vocabulary) thread but it is nice to be able to group words into relevant vocabs - a little like having directories on a disk system.

There is a down side though. In a single vocab system you can redefine a word and be pretty sure it will supersede the earlier version. With multiple vocab it is possible to have the same word in different dictionaries and become confused about which one is being used. This is a particular problem when meta-compiling. Most people don't meta-compile so it is mainly your's truly who gets bitten.

The sort of thing that happens is I want to rebuild the compiler and change to locations of a word. What can happens is the wrong(old) version of the word get used and bad things happen.
If you look at the kernel code you'll see a lot of words get "smudged" before being redefined so this can't happen.

The other trap is the assembler and compiler automatically place the assembler and compiler dictionaries on the stack when defining a new word and remove them afterwards. This causes problems if the assembler and compiler words exist in other vocabs. Most other languages simply don't let you refined "reserved" words but in forth you can.

Here is a demo of the vstack words. Unfortunately the wiki has screwed up the formating.
The line starting with the > prompt are my input stuff after // are my added comments.

>.V // this lists the vocab stack - it shows the forth vocab.

Search order -->
FORTH

> VDROP // I drop the top of the Vstack - this means there are no active vocabs - not good.

> FORTH // I type a word - any word - it can't be found therefore we crash.

???
EMFORTH v1.08 for the SAM7 ARM micro controller
E.Matejowsky 2007

> FORTH // the abort routine always places the forth vocab (only) on the vstack. This call to forth is redundant.

> COMPILER // add compiler vocab.

> .V // list them.

Search order -->
COMPILER
FORTH

> RUNTIME // add runtime vocab

> .V // list them.

Search order -->
RUNTIME
COMPILER
FORTH

> COMPILER // add compiler again.

> .V // list them and note the order has changed.

Search order -->
COMPILER
RUNTIME
FORTH

> VLIST // list the words in the top vocab (compiler).


202598 ^ WHILE 202574 UNTIL 20249C IF 20247C LOOP
202460 DO 202448 BEGIN 202430 EXIT 202408 REPEAT
2023E8 THEN 2023B8 ELSE 202384 PATCH 20222C ;
202210 [ 201EF8 LITERAL 201ED8 GOTO 201EBC BR
201E9C CALL 201E7C BRLNK 201E38 -BR

> VDROP // drop compiler vocab


> .V // show it has gone.


Search order -->
RUNTIME
FORTH

> VLIST // list the words in the top (runtime) vocab.


202E54 MIRRORPA 202E3C USER 202E14 DELAY 202DC4 LOCK64K
202D70 LOCKALL 202D1C UNLOCKAL 202CCC SETLOCK 202C7C CLEARLOC
202C50 WAITFREA 202C2C READFMOD 202C08 READFSTA 202BF0 CPUMHZ
202BD4 FLASHKEY 202BBC MCBASE 202BA4 MC_FSR 202B8C MC_FCR
202B74 MC_FMR 202B5C SSB 202B44 CGPB 202B2C SGPB
202B18 EA 202B00 CLB 202AE8 WPL 202AD0 SLB
202ABC WP 20298C SDASC 2028E0 COLD 202888 INITPORT
202824 INIDATA 202804 RSTC_URS 2027E8 RSTC_MR 2027CC base_RST
2027AC US_CHRL_ 20278C US_PAR_N 202768 US_NBSTO 202748 US_CLKS_
202724 US_USMOD 202708 PA22_TXD 2026EC PA21_RXD 2026D0 PIOA_PDR
2026B8 RSTSTA 20269C US_TXDIS 202680 US_TXEN 202664 US_RXDIS
202648 US_RXEN 20262C US_RSTTX 202610 US_RSTRX 2025F8 ID_US1
2025E0 ID_US0 2025C4 ID_PIOA 2025A8 PMC_PCER 200754 RESET
200738 [LIT] 200718 [DO] 2006EC [LOOP] 2006CC [IF]
200338 RSTACK 200320 DSTACK 200308 *ABORT 2002EC [VAR]
2002D0 F_THUMB 2002B8 F_VOCB 2002A0 F_SMUD 200288 F_REMT
200270 F_OFFS 200258 F_IMMD 200240 BPW 200224 US_RXRDY
200208 US_TXRDY 2001EC US_BRGR 2001D4 US_RHR 2001BC US_THR
2001A4 US_CSR 20018C US_MR 200170 BASE_US1 200158 LEDBIT
20013C PIO_SODR 200120 PIO_CODR 200104 PIO_OER 2000E8 PIO_PER
2000CC [CON]

>
Created by eddie. Last Modification: Thursday 26 of July, 2007 20:35:59 AEST by eddie.

Main Index

Switch Theme

Shoutbox

System Administrator, 13:56 AEST, Sun 07 of Aug, 2016: upgrading to tiki 15.2
eddie, 19:31 AEST, Sat 06 of Aug, 2016: This website is now served from Brisbane - in a Binarylane cloud.
System Administrator, 16:07 AEDT, Wed 06 of Mar, 2013: More f'n spam. No more anon posting from now on.
Anonymous, 18:44 AEDT, Mon 04 of Mar, 2013: deleted
Anonymous, 08:36 AEDT, Sun 03 of Mar, 2013: Very nice site!

Last-Visited Pages

Online Users

62 online users