jrd wrote
So, in this Chapter 7, the book specifies that base Temp register is allocated to R[5].
However - unlike SP, LCL, ARG, THIS & THAT - TEMP is not defined as specifically R[5] in the symbol table we constructed back in Chapter 6 for our binary Assembler.
Should we be revising the symbol table as such in the Assembler code, or are their circumstances where TEMP != R[5], in which case we should translate TEMP manually to a reference to R[5] in the VM translator at runtime.
"temp" is a segment, not a register. The VM reference "temp
n" refers directly to RAM[5+
n]; there is no pointer register involved. "pop temp 3" will generate code like this:
[code to pop the stack into the D register]
@8
M=D
Since the assembler can't parse something like "TEMP+3" there is no reason to add TEMP as a predefined symbol. (It might be an interesting project to add expressions to @ commands!)
--Mark