Chapter 4- Machine Language Flashcards
What is the name of the program that translate assembly code to binary code?
Assembler
What are the 3 options to specify and address in assembly code?
- Direct accessing: express a specific address or use symbol for that address- LOAD R1,67 // R[1] <- 67
- Indirect addressing: address mode to handle pointers. The instruction specifies memory location that holds the required address
Indirect addressing example: x = foo[j];
Write it in assembly
Add R1, foo,j // R1 = foo+j
LOAD R2,R1
STR R2, x
What is the hack computer?
16 bit machine builds from CPU, two memory modules- instruction memory and dat memory and two memory mapped i/o devices.
It also has two registers: D and A. They ar 16 bit
What is the instruction memory?
It is a read only memory of size 32k 16 bit words
What D register is used for?
To store data.
What A is used for?
Data register and address register. Means as address In the data memory or address in the instruction memory.
For the instruction memory, jump operations always effect a jump to the instruction located In the memory address by A.
Goto 35, first set A to 35 and then just goto command
What is M?
Memory access instructions operate on an implicit memory location labeled M.
M always refers to the memory word who’s address is the current value of A.
D =Memory[516] - 1 so first set A = 516 and then D = M - 1;
What is @value
Store value in A. It is the A instruction
How many commands to I need when memory location is involved?
Two: one for selecting the address and the second is to operate on the memory location of that address.
Because of that there is the A instruction and the C instruction
To compute
What M stands for?
memory[A]
What is the format of C instruction?
111a ….
How to increment memory[7] and also store it in D?
@7
MD=M+1
What is a prequisiof a jump?
That A register holds the value of the instruction line to jump to.
If there is a jump we should avoid using
Register M because it can get conflicted with the A register that holds the place to jump.