Hello
I'm a beginner with AVR assembler and Forth in general, but it seems
to me that there is a problem with parameter stack pointer (Y
register) initialization in amforth.
I tried to run amforth in AVR Studio simulator, maybe there are some
differences with real hardware that I'm not aware of. Anyway, amforth
1.6 crashed in the simulator.
I have narrowed the problem to the start of COLD codeword that first
calls SP0 to fetch the address of the stack (that should be
stackstart) and then SP! to store the top of stack value to Y
register.
The problem is that SP0 returns its value on the stack while Y
register is still uninitialized and contains XT_NOOP address (from
reset routine). In the SVN this problem may be a bit hidden because
top of stack is kept in a register pair, but the execution will start
with savetos macro that uses Y register anyway and might corrupt the
RAM anyway.
I think that this could be solved by adding word SP0! that just loads
Y with stackstart value or by moving in amsforth.asm, reset routine
the parameter stack pointer initialization just before the jump to
Forth machine so that Y register will have the value of stackstart.
Best regards,
Maciej
|