Local Segment

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

Local Segment

TickTack
Hello,
I am not sure if I understand how segments work.
Local segment stores local variables of FUNCTION.

projects/07/MemoryAccess/BasicTest/BasicTest.vm:
push constant 10
pop local 0
...

What does "local 0" mean in this case? There is no FUNCTION in this file.
Reply | Threaded
Open this post in threaded view
|

Re: Local Segment

culchie
Functions don't come until Ch 8 so, I'd guess that it is just testing that you are using the various segments correctly which is one of the goals of Ch 7.
Reply | Threaded
Open this post in threaded view
|

Re: Local Segment

Francisco José Tornay Mej
In reply to this post by TickTack
Yes, it's just for testing segments but it may help to know that, at this stage, all "local 0" means is the memory cell whose address equals the value stored at LCL (Ram[1]) plus the index 0. That's the way local vars will be implemented in the next chapter.