Error while calling memory.poke() function

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Error while calling memory.poke() function

sarthak
I wrote a jack code where I tried to access (using Memory.poke() function) a memory location 1024 for writing but when I ran the compiled VM code on the VM Emulator. This poke() function gave an error saying:
A built-in function tried to access the memory outside the Heap or Screen range.
Is this error due to my writing on some read-only memory?
How can I remove this error?
The code if needed is also attached.snakegame.zip
Reply | Threaded
Open this post in threaded view
|

Re: Error while calling memory.poke() function

ybakos
The heap starts at address 2048.

Why are you trying to poke a value into address 1024?

Reply | Threaded
Open this post in threaded view
|

Re: Error while calling memory.poke() function

cadet1620
Administrator
In reply to this post by sarthak
sarthak wrote
I wrote a jack code where I tried to access (using Memory.poke() function) a memory location 1024 for writing but when I ran the compiled VM code on the VM Emulator. This poke() function gave an error saying:
A built-in function tried to access the memory outside the Heap or Screen range.
Is this error due to my writing on some read-only memory?
How can I remove this error?
Memory addresses below 2048 are not physically read-only, but they should not be written to because that memory has specific uses. 0-15 is used for the VM's pointers and temporary variables, 16-255 is used for the VM's static variables, and 256-2047 is used for the stack.

peek() and poke()should not be needed in ordinary programming. They might be useful if you want to write some more sophisticated keyboard or graphic handling than is provided by the built-in OS functions.

--Mark