[<<][staapl][>>][..]
Mon Jul 21 21:47:47 EDT 2014

Stack is growing

(test4)
(call-word target/init-notes)

(>d 1) (call-word target/notes-add)    (dump) (ds)
(>d 1) (call-word target/notes-remove) (dump) (ds)

notes-remove causes stack to grow

it doesn't do that on target though.
looks like a sim problem.

it's doing a 256 byte loop when the buffer is empty

maybe this happens on target as well?  would explain why bytes from
the serial buffer are shifting up!

next: make some tests for that notes.f code
it's too messy anyway.

Looks like notes-pop was wrong: for loop count is inverted.

wrong:

: notes-pop \ index --
    dup 1 + a!notes+       \ point past first element to remove
    nb-notes @ - for
        @a- dup >a >a
    next
    1 nb-notes -! ;


right:

: notes-pop \ index --
    dup >r 1 + a!notes+       \ point past first element to remove
    nb-notes @ r> - for
        @a- dup >a >a
    next
    1 nb-notes -! ;



so what is there to learn?
- don't mess with for .. next if there is ever a 0 case.  use a more abstract word.
- don't write branching code (if/then/else hell)

not that i didn't already know that.  i guess this was a slip of discipline..


macro
: 0=? 0 addlw z? ;  
: _for  0=? if drop else for ;
: _next next then ;
forth


yeah it's not working still so probably time to start over.

basic operations:
- add element to front of list if not already present
- remove element from list
- get first element


maybe linked lists are a better primitive? they would sure be useful
in other applications.  and it should be straightforward to write a
proper test suite in the emulator.



[Reply][About]
[<<][staapl][>>][..]