{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

hw_4_solution

# hw_4_solution - Homework#4 solution 1 We want to increase...

This preview shows pages 1–3. Sign up to view the full content.

Homework #4 solution 1. We want to increase the number of registers that we can specify in the LC-3 AND instruction to 16. Do you see any problem with that? Explain. Ans) YES, there’s a problem. Not enough bits in the instruction to have 4 bit registers. 2. Implement a XOR gate (A XOR B) using the LC3 instruction set. Assume that the 2 numbers are given at R0 and R1. (Hint: Use DeMorgan’s Laws. LC3 doesn’t have an OR function) A XOR B = ( AB’ + A’B) = (( AB’ + A’B)’)’ = ((AB’)’ * (A’B)’)’ A is in R0 and B is in R1 NOT R2,R0 ; A’ NOT R3, R1 ; B’ AND R4,R0,R3 ; AB’ AND R5,R2,R1 ; A’B NOT R4,R4 ;(AB’)’ NOT R5,R5 ; (A’B)’ AND R6,R4,R5 ; (AB’)’ * (A’B)’ NOT R6,R6 ; ((AB’)’ * (A’B)’)’ 3. Write the condition code at the end of each instruction (assume the program starts at memory location x3000): Instruction N Z P Initial case 0 0 1 0 0 1 LEA R2, #100 0 0 1 LD R2, #0 You are loading “ADD R3, R2,0x5” into R2, so it should be possitive 0 0 1 ADD R3, R2,0x5 0 0 1 ADD R4,R2,#-11 0 0 1 AND R5,R5,#0 0 1 0 NOT R6, R5 R6 has 111111 1 0 0 ST R6, #200 1 0 0 Do the condition codes depend on the NZP values of the previous instructions?

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Yes.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 4

hw_4_solution - Homework#4 solution 1 We want to increase...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online