> Programmingkid wrote:
>
>>> Is there a reason that you're not using the in-built debugger for this?
>>> I'm fairly sure it would make your life much easier.
>>
>> I'm making code that will associate a value with a function name and will store both in a table. Thank you Mark and Stefan for helping.
>
> It sounds as if you're working with Forth at quite a low level. Perhaps
> you should consider breaking the task down into small chunks and then
> posting patches to the list for feedback? Then people can offer more
> guidance to help you.
>
>
> ATB,
>
> Mark.
This is what I am trying to do. I am making a word called '{' that will read each symbol after it and load it into memory. Here is my code so far:
variable currentWordAddr
variable currentWordLen
/ copies the current words name
/ must be called at beginning of '{' word
: copyWordName ( - addr len)
ib >in @
dup
alloc-mem
swap
2dup
>r
>r
move
r>
r>
currentWordLen !
currentWordAddr !
;
: {
copyWordName
begin
parse-word dup 0>
while
2dup drop " }" comp 0=
if exit then
2dup drop " ;" comp 0=
if false useTopStackValue !
else currentWordAddr @ currentWordLen @ loadLocalVariable
then
repeat
does> copyWordName
; immediate
copyWordName simply copies the word name that comes before the '{' and after the ':'. I am trying to make the '{' word have a compile-time behavior of loading each symbol after the '{'. It stops when '}' is encountered. So if this word is being compiled : hi { dog cat hamster }
the '{' word will send dog, cat, and hamster to loadLocalVariable. At run-time, it should only call copyWordName to load the current word being ran.
I simply don't know how to do both compile and run-time behaviors that I want. Anyone know how to do this? This is my starting point for local variable support in OpenBIOS.