Little bit lost. Dont know where to put STATIC, LOCAL etc. So for example RAM holds address of the base of THIS. But where should RAM point? Will the compiler have to figure out how to arrange for THIS not to run out of room? Or is there a standard?
Should I be thinking of compiler running through a program to get information on how big stuff has to be before hand.. and then putting things .... in what? the 'heap' from 2048 to 16483? So if I decided to do THIS and THAT first then I would have to know that let's say THIS is going to need at most 10 places. So I would set RAM to 2048 and RAM to 2058?
By the way love this course! It's daunting but very exciting too:)
RAM holds address of the base of THIS. But where should RAM point?
You've answered your own question here, but let's clarify. RAM has a handy nickname: THIS. The THIS register stores the base address of the this memory segment. Hence, THIS points to this.
If you have programmed with object-oriented languages, you should be able to infer that THIS really is a pointer to an object, and the this segment does indeed represent the memory occupied by that object.
THAT and that are similar, but these are used by the Jack language for arrays.
Note that the that segment does not necessarily come right after the this segment on the heap. They can be anywhere in the heap.
If THIS points to address 3000, and the object stored there has three member variables, how big is the this memory segment? What addresses does it occupy?
RAM holds 0000101110111000 (binary for 3000)
RAM, RAM and RAM hold 16*3 bits of whatever data
RAM is potentially available for something else.
A variable can be only as large as 2's complement can handle in 16 bits.
Is this right?