Debugging words not being found
diff --git a/BUGS.TXT b/BUGS.TXT
new file mode 100644
index 0000000..e1fb972
--- /dev/null
+++ b/BUGS.TXT
@@ -0,0 +1,14 @@
+!! BUGS !!
+
+- For some reason, if the word `IMMEDIATE' is defined in DICTNRY.ASM,
+ it shows up in `WORDS' but cannot actually be invoked. If it is
+ shortened to `IMMED' it works fine, same if it's called
+ `IMMEDIAT'. However, `IMMEDIATX' doesn't work. But if it's named
+ something random like `123456789' it works. Also, other words 9
+ characters long work fine! This is really weird. Moving the
+ definition of `IMMEDIATE' to a different location in the binary
+ (padding it from the start) doesn't solve the problem.
+
+ Update: This seems to affect a whole lot of words, including
+ `>CFA'. Can't seem to find a pattern between them, e.g. `>DFA' works
+ fine.
diff --git a/CORE.F b/CORE.F
index 74aff9d..b844633 100644
--- a/CORE.F
+++ b/CORE.F
@@ -4,21 +4,21 @@
: / /MOD NIP ;
: MOD /MOD DROP ;
-: LITERAL IMMEDIATE ' LIT , , ;
-: [COMPILE] IMMEDIATE WORD FIND >CFA , ;
-: RECURSE IMMEDIATE LATEST , >CFA , ;
+: LITERAL IMMED ' LIT , , ;
+: [COMPILE] IMMED WORD FIND >CFA , ;
+: RECURSE IMMED LATEST , >CFA , ;
\ Control structures
\ cond IF <*b0> true ELSE false THEN rest
-: IF ( -- *then ) IMMEDIATE ' 0BRANCH , HERE @ 0 , ;
+: IF ( -- *then ) IMMED ' 0BRANCH , HERE @ 0 , ;
-: THEN ( *then -- *then ) IMMEDIATE
+: THEN ( *then -- *then ) IMMED
DUP HERE @ SWAP ( *then *then *here )
SWAP - ( *then *here-*then )
SWAP ! ;
-: ELSE ( *then -- *here ) IMMEDIATE
+: ELSE ( *then -- *here ) IMMED
' BRANCH ,
HERE @ ( *then *ph )
0 ,
diff --git a/DICTNRY.ASM b/DICTNRY.ASM
index 7a78fe8..bc9689e 100644
--- a/DICTNRY.ASM
+++ b/DICTNRY.ASM
@@ -26,9 +26,9 @@
NEXT
- ;; BX - Word
+ ;; BX - Word entry on dictionary
;; CX - Length
- ;; DI - Name
+ ;; DI - Name to compare to
;;
;; All three parameter registers may be clobbered.
;;
@@ -105,7 +105,6 @@
ADD BX, 2 ; 1 to round up, 1 to skip length
AND BX, (~1) ; Zero the last bit
-
PUSH BX
NEXT
@@ -188,7 +187,7 @@
NEXT
- DEFWORD_RAW_IMMEDIATE IMMEDIATE, 'IMMEDIATE'
+ DEFWORD_RAW_IMMEDIATE IMMEDIATE, 'IMMED'
MOV BX, [VAR_LATEST]
XOR BYTE [BX + 2], IMMEDIATE_BIT
NEXT
@@ -265,6 +264,7 @@
DW STATE, GET ; ( cfa immediate? interpreting? )
;; In either case evaluate
DW ZEROBRANCH ; ( cfa immediate? )
+ ;; We are currently interpreting:
RELATIVE_ADDRESS .WORD_IMMED
DW ZEROBRANCH ; ( cfa )
RELATIVE_ADDRESS .WORD_COMPILE_IMMED
@@ -275,12 +275,15 @@
.WORD_IMMED: ; ( cfa immediate? )
DW DROP ; ( cfa )
-.WORD_COMPILE_IMMED:
+.WORD_COMPILE_IMMED: ; ( cfa )
DW EXECUTE ; ( )
DW EXIT
.NUM: ; ( addr len 0 )
DW DROP ; ( addr len )
+ INCLUDE_STRING 'Parsing as a number'
+ DW TYPE, CR
+ DW _2DUP, TYPE, CR
DW NUMBER ; ( number unparsed )
DW ZEROBRANCH ; ( number )
RELATIVE_ADDRESS .NUMOK
diff --git a/FORTH.ASM b/FORTH.ASM
index 19c184f..53bae75 100644
--- a/FORTH.ASM
+++ b/FORTH.ASM
@@ -305,7 +305,7 @@
;;; LATE-INIT VARIABLES ;;;
DEFVAR STATE, 'STATE'
- DW 0 ; Interpret
+ DW 0 ; Interpret; ( cfa )
DEFVAR HERE, 'HERE'