[NTLK] NEWT/0 set-aref bug
matej.horvat at guest.arnes.si
Mon Dec 15 15:33:43 EST 2014
I have discovered a bug in NEWT/0.
Suppose we have the following function:
local A := [0, 0];
A := 1;
A := 2;
NEWT/0 incorrectly compiles the array assignments. It generates:
There should be a pop instruction after each set-aref, because the result
is not used.
When returning from the function, the stack pointer is in this case 2
higher than it should be, which causes problems in NSM, which has a fixed
size stack. I am not sure how the Newton OS reacts to this.
I have already informed Makoto Nukui of this. I am just reposting this
here as a warning as DyneTK and tntk both use NEWT/0, so they are also
affected (I can reproduce the bug in both).
A workaround may be to use a function like
func(Array, Pos, Value)
ArrayMunger(Array, Pos, 1, [Value], 0, 1)
and a similar kludge involving StuffByte and Ord for strings, but that is
of course inconvenient.
More information about the NewtonTalk