Peer Instruction 6 LC3 Assembly Language continued Translate
Peer Instruction #6: LC-3 Assembly Language (continued)
Translate the LC-3 instruction 0 x 4840 into LC-3 assembly code: A. B. C. D. E. JSR Label (Label at PC + 0 x 3 F) JSR Label (Label at PC + 0 x 40) JSRR R 3 JSRR R 1 None of the above
Translate the LC-3 instruction 0 x. C 1 C 0 into LC-3 assembly code: A. B. C. D. JMP R 7 RET Both of the above None of the above
Translate ADD R 0, R 1, x 10 from assembly code into an LC-3 instruction in hexadecimal: A. B. C. D. E. 0 x 1040 0 x 106 F 0 x 1070 0 x 107 F Cannot be done!
DATA . FILL 0 x 1234 LD R 5, DATA AND R 5, #15 NOT R 5, R 5 What value is in R 5 after the above code? A. B. C. D. E. 0 x 123 F 0 x. EDCB 0 x. FFFC None of the above
. ORIG x 3000 AND, R 1, #0 ADD R 1, R 0, #1 BRp MAIN Is the branch taken in the above code? A. B. C. D. E. Yes No Depends on initial value of R 0 Depends on initial value of R 1 None of the above
Which instruction branches to Main if R 0 is less than or equal to 12? Twelve Main . FILL x 000 C LD R 1, Twelve NOT R 1, R 1 ADD R 1, 1 ADD R 0, R 1 ? ? ? Main A. B. C. D. E. BRn BRz BRp BRnz BRzp
What is the value in R 0, and the instruction associated with the LOOP label when the program reaches the HALT command? A. 5, ADD R 0, #3 AND R 0, #0 ADD R 1, R 0, #2 B. 8, ADD R 0, #7 LOOP ADD R 0, #3 C. 3, ADD R 0, #5 LD R 2, LOOP ADD R 2, #2 D. 7, AND R 0, #7 ST R 2, LOOP E. None of the above ADD R 1, #-1 BRp LOOP HALT
What are the values in R 0, R 1, R 2 after the code below executes? Assume the Main label is at address x 3000. Main LD R 0, Data LEA R 1, Data LDR R 2, R 1, 0 HALT Data . FILL 0 x 4321 A. B. C. D. E. x 4321, x 3003, x 7324 x 4321, x 3004, x 7324 x 4321, x 3003, x 4321, x 3004, x 4321 None of the above
What is the value in R 0 and R 1 after the code executes from Main label? Array. FILL x 1133. FILL x 2244. FILL x 3355 Main NOT R 1, R 1 LEA R 2, Array LDR R 0, R 2, 2 LDR R 1, R 2, 3 HALT A. B. C. D. E. x 1133, x 2244, x 3355, x 903 F x 3355, x 927 F None of the above
What is the PC offset field in the ST instruction shown below? Data 0 Data 1 Data 2 Main . FILL x 1234. FILL x 2345. BLKW 1 LD R 1, Data 0 LD R 2, Data 1 ADD R 3, R 2, R 1 ST R 3, Data 2 A. B. C. D. E. 0 b 111111011 0 b 111111100 0 b 111111101 0 b 100000100 0 b 100000101
Match the LD R 0, Var assembly instruction to the corresponding C statement LC 3 Assembly. ORIG var. FILL ptr. FILL LD R 0, Code: x 3000 x 0004 x 3000 var C Code: int var = 4; int *ptr = &var; int R 0; // what goes here? A. R 0 = var; B. R 0 = &var; C. R 0 = *ptr; D. None of the above E. All of the above
Match the LEA R 0, Var assembly instruction to the corresponding C statement LC 3 Assembly Code: . ORIG x 3000 var. FILL x 0004 ptr. FILL x 3000 LEA R 0, var C Code: int var = 4; int *ptr = &var; int R 0; // what goes here? A. R 0 = var; B. R 0 = &var; C. R 0 = *ptr; D. None of the above E. All of the above
Match the LDI R 0, Ptr assembly instruction to the corresponding C statement LC 3 Assembly Code: . ORIG x 3000 var. FILL x 0004 ptr. FILL x 3000 LDI R 0, ptr C Code: int var = 4; int *ptr = &var; int R 0; // what goes here? A. R 0 = var; B. R 0 = &var; C. R 0 = *ptr; D. None of the above E. All of the above
Match the LD R 1, PTR and LDR R 0, R 1, #0 assembly instructions to the corresponding C statement LC 3 Assembly Code: . ORIG x 3000 var. FILL x 0004 ptr. FILL x 3000 LD R 1, ptr LDR R 0, R 1, #0 C Code: int var = 4; int *ptr = &var; int R 0, R 1; // what goes here? A. R 0 = var; B. R 0 = &var; C. R 0 = *ptr; D. None of the above E. All of the above
- Slides: 15