Chapter 7 Flashcards
What does the VM Translator do?
It turns virtual machine code into assembler code.
- At what memory location of the Hack’s RAM is the stack pointer saved?
- What is the stack’s base address in the Hack computer?
What is the translation of the virtual machine command:
“push constant 17”
in Hack assembly?
What is the logic for turning the VM code command:
“pop local 2”
int Hack machine code?
What gets stored in the following memory segments of the Hack’s RAM:
local
argument
this
that
?
What are the stages that make the result of a high level Jack program appear on the Hack screen?
What is the standard VM mapping on the Hack platform?
We want to write “pop local 2” in Hack assembly.
What is the first step?
What Hack code achieves this step?
The first step is to have a variable (D) that will hold the address to which we want to save the poped data.
//D = LCL + 2
@LCL
D=M
@2
D=D+A
- What is the minimal number of Hack commands for the VM code: Push constant i
- What are these commands?
- What is the minimal number of Hack commands for the VM code: Pop temp i
- What are these commands?
(Base address of temp is 5)
- What is the minimal number of Hack commands for the VM code: Pop (argument/local/this/that) i
- What are these commands?
What will the bottom of the stack be like after:
push 5
push 3
sub
push -3
push 10
sub
2
-13
let x be any number.
What will the bottom of the stack look like after:
push x
push -1
and
the last item on the stack will be:
x
This is because an and operation between any number and “111…111” (= the binary representation of -1) gives back the same number.
push 101101
push x
or
What value of x will give us the first number pushed?
00000
Let x be any value.
What will the bottom of the stack look like after?
push 0000
push 1111
push x
and
or
x