TEMP 6 or temp6 ?

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

TEMP 6 or temp6 ?

Christer Nilsson
First of all, this course is dynamite. I have a M Sc in Computer Science from 1981 and really appreciates this holistic perspective!

But, I can't get the BasicTest to work. I think it has to do with the segment TEMP, being treated differently in different parts of the software.
"pop temp 6" is used in BasicTest.vm but in the Virtual Machine Emulator other names are used:

Screen Dump

I can understand the reason for using Temp6 instead of "temp 6" as the addition of 5+6 is not needed.
But no matter of what names I use, I end up with the variable pointing at address 16 and upwards.
I can't see any other reason for "Temp6" and I think treating TEMP the same as SP, LCL, ARG, THIS and THAT is easier to understand. If not, the differences should be clearly stated. R13, R14, ... already has this property, so there is no need to duplicate that in TEMP.
Reply | Threaded
Open this post in threaded view
|

Re: TEMP 6 or temp6 ?

cadet1620
Administrator
This post was updated on .
There are no built-in assembly language variables named "Temp*". Your VM translator must write code that directly references RAM[5+n] for "push/pop temp n".

--Mark
Reply | Threaded
Open this post in threaded view
|

Re: TEMP 6 or temp6 ?

ybakos
In reply to this post by Christer Nilsson
"I think it has to do with the segment TEMP, being treated differently in different parts of the software.
"pop temp 6" is used in BasicTest.vm but in the Virtual Machine Emulator other names are used: "

Not quite. There is definitely a relationship between the VM layer's notion of the local segment and the value in the LCL register. The value in the LCL register represents the base address of the local segment. While temp refers to the temp virtual memory segment, this virtual memory segment has a fixed place in physical ram: R5 - R12. The fact that the GUI labels R5 - R12 as Temp0 - Temp7 is just a convenience in the VM emulator, to allude to the relationship between R5 - R12 and the temp virtual memory segment.
Reply | Threaded
Open this post in threaded view
|

Re: TEMP 6 or temp6 ?

Christer Nilsson
Thanks, I realised my erroneous thinking when skipping to the PointerTest.
Reply | Threaded
Open this post in threaded view
|

Re: TEMP 6 or temp6 ?

linuxford
In reply to this post by cadet1620
Thank you Mark for being explicit and very clear.

I've been stumped on this one for many evenings. Finally went searching in the forums and found this. I got this particular bug fixed, thank you!