bobbimanners / EightBall

The Eight Bit Algorithmic Language for Apple II, Commodore 64 and VIC20
GNU General Public License v3.0
19 stars 3 forks source link

Array pass by reference does not work for local array #21

Closed bobbimanners closed 6 years ago

bobbimanners commented 6 years ago

If the array is global, it works okay:

This is okay.

word A[10]=0
call foo(A)
end
sub foo(word A[])
  bar(A)
endsub
sub bar(word A[])
 ...
endsub

However, this fails:

call foo()
end
sub foo(word A[])
  word A[10]=0
  bar(A)
endsub
sub bar(word A[])
 ...
endsub

It is almost certainly a screwup with relative vs absolute addresses.

bobbimanners commented 6 years ago

More precisely, the problem is that taking the address of a local array in compiled code gives a relative address. Needs to be an absolute address to be useful. This works fine for scalar variables (taking address of local gives absolute address). It also works fine in the interpreter for arrays.

bobbimanners commented 6 years ago

Fixed in v0.61