Out of bounds detection VM

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

Out of bounds detection VM

Tim
Hey everyone!

First of all, I'd like to say that I'm learning a lot from this course and I'm having a lot of fun on the way as well!
I was wondering while working on VM I about detecting the borders of your registers.
For example, we use the the fixed 8 entry segments for the 'temp' segment in the RAM. But on what level do you begin to detect whether someone is actually still writing in that part?
What if someone ask for 'push temp 10'? Do we save it in R15? Or in temp 7 anyways? Or is this a command that cannot occur due to a higher layer (e.g. VM II or High Level Language)?

Thanks in advance!

Tim
Reply | Threaded
Open this post in threaded view
|

Re: Out of bounds detection VM

cadet1620
Administrator
Tim wrote
I was wondering while working on VM I about detecting the borders of your registers.
For example, we use the the fixed 8 entry segments for the 'temp' segment in the RAM. But on what level do you begin to detect whether someone is actually still writing in that part?
What if someone ask for 'push temp 10'? Do we save it in R15? Or in temp 7 anyways? Or is this a command that cannot occur due to a higher layer (e.g. VM II or High Level Language)?
Since the VM code is indended to be written by the Jack Compiler, and not by humans, it is assumed to be error free, so there is no need to deal with out-of-bounds issues.

My VM Translator does no bounds checking. It might be helpful for debugging the compiler, however, to issue a message and abort the translation on out-of-bounds errors.

--Mark

Tim
Reply | Threaded
Open this post in threaded view
|

Re: Out of bounds detection VM

Tim
Thanks for the quick reply!
This was exactly what I hoped to hear :)