Chapter 4 Flashcards

1
Q

What are A and D in Hack programing?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the A instruction in the Hack programing language?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the C instruction in the Hack programing language?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

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?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How are lables declared and used in Hack programing language?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How are variables declared and used in Hack programing language?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain the first 4 lines of the Hack code in the picture:

A

@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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do the bits in the “comp” field of the C instruction actually cause computation?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly