diff --git a/apps/forth/dict.asm b/apps/forth/dict.asm index 911fd4f..48eaf61 100644 --- a/apps/forth/dict.asm +++ b/apps/forth/dict.asm @@ -430,11 +430,22 @@ ALLOT: .dw STOREINC+CODELINK_OFFSET .dw EXIT+CODELINK_OFFSET +; CREATE 2 ALLOT +VARIABLE: + .db "VARIABLE" + .dw ALLOT + .dw compiledWord + .dw CREATE+CODELINK_OFFSET + .dw NUMBER + .dw 2 + .dw ALLOT+CODELINK_OFFSET + .dw EXIT+CODELINK_OFFSET + ; ( n -- ) ; CREATE HERE @ ! DOES> @ CONSTANT: .db "CONSTANT" - .dw ALLOT + .dw VARIABLE .dw compiledWord .dw CREATE+CODELINK_OFFSET .dw HERE_+CODELINK_OFFSET diff --git a/apps/forth/dictionary.txt b/apps/forth/dictionary.txt index 16cb7c5..bc2e7c3 100644 --- a/apps/forth/dictionary.txt +++ b/apps/forth/dictionary.txt @@ -25,7 +25,7 @@ DOES>: Used inside a colon definition that itself uses CREATE, DOES> transforms - a b -- c a - b -> c * a b -- c a * b -> c / a b -- c a / b -> c -CREATE x -- Create cell named x +CREATE x -- Create cell named x. Doesn't allocate a PF. DOES> -- See description at top of file DUP a -- a a EMIT c -- Spit char c to stdout @@ -45,3 +45,4 @@ SWAP a b -- b a +! n a -- Increase value of addr a by n ALLOT n -- Move HERE by n bytes CONSTANT x n -- Creates cell x that when called pushes its value +VARIABLE c -- Creates cell x with 2 bytes allocation.