Chapter 4 Flashcards
What are A and D in Hack programing?
What is the A instruction in the Hack programing language?
What is the C instruction in the Hack programing language?
Assembly commands can refer to memory locations (addresses) using either constants or symbols.
Besides predefined symbols, what are the two types of symbols used in assembly programs?
Label symbols: These user-defined symbols, which serve to label destinations of goto commands, are declared by the pseudo-command ‘‘(Xxx)’’. This directive defines the symbol Xxx to refer to the instruction memory location holding the next command in the program. A label can be defined only once and can be used anywhere in the assembly program, even before the line in which it is defined.
Variable symbols: Any user-defined symbol Xxx appearing in an assembly program that is not predefined and is not defined elsewhere using the ‘‘(Xxx)’’ command is treated as a variable, and is assigned a unique memory address by the assembler, starting at RAM address 16 (0x0010).
How are lables declared and used in Hack programing language?
How are variables declared and used in Hack programing language?
Explain the first 4 lines of the Hack code in the picture:
@R1 // A holds the address: 1
D = M // (M holds the contents of memory at address 1), therefore D = memory[1].
@temp // A holds some random empty address now called “temp”.
M = D // memory[temp] = memory[1], which is the same as: temp = R1
How do the bits in the “comp” field of the C instruction actually cause computation?
The “comp” field instructs the ALU what to compute.
this is because the bits of the comp field in the C instruction are the bits that are fed to the ALU as control bits.