This is the file downloaded it also has the jack and vm code. what's wrong?. Is there any thing wrong with the file i downloaded. Can you run the vm code and check
Re: A built-in function tried to access memory outside the Heap or Screen range
A built-in function could be doing this because of the way it's called. As a rule of thumb, always check if your code is the problem before trying to find bugs elsewhere.
You can attach your code here or you can send it via email to me and I'll see what I can find.
First of all, it would be helpful to place this question in one of the appropriate subfolders in this forum (in this case I would presume project 9 is the right place since it is Jack language related. Furthermore, it is easier to understand if you just include the relevant source code section directly in the post and describe exactly what you are trying to achieve and what didn't work.
I presume that your question is related to the file main.jack in the tools folder.
That shows already the first mistake: Jack is case sensitive. And by convention class names should begin with a capital letter. If you open a folder (not a file) with the VM Emulator it will look for Main.vm which should include the VM Code for the class Main (not main).
Therefore: rename the file to Main.jack, change the class name inside the file to Main, and recompile.
Secondly, your source code contains calls that are not complying with the defined API of the OS routines. Check in the book or in the nand2tetris documentation (or in the OS stub files under project 12) the API of the respective OS routines and which parameters are required.
Re: A built-in function tried to access memory outside the Heap or Screen range
Please describe the error or the bad behavior that you see.
One possible problem that I saw is with the line s.appendChar(33); Internally String objects contain arrays of ints (chars). If the array is already full, then this method should fail with an error. If it doesn't check properly, then it would just corrupt the memory and this can result in unpredictable behavior.
The string s is constructed by the call to Keyboard.readLine(). It very well might return a string that is just big enough to contain the read line.
Re: A built-in function tried to access memory outside the Heap or Screen range
Broadly speaking there are at least two ways. Firstly, you can create a bigger string, copy the existing one and add the additional characters that you need. In Jack the memory is managed manually, so you'll have to remember to free up the allocated memory.
The second approach is easier, at least for this specific case. You can just print the string as it is, and then print the additional exclamation mark as a separate call.