{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

exam2-a-fall07-soln

# exam2-a-fall07-soln - ECE 109-001 NC State University Exam...

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

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ECE 109-001 Name:____________________________________________ NC State University Exam 2(A): 5 November 2007 1 1. (20 points) Write a statement or a short sequence of statements in LC-3 assembly language that accomplishes each of the following actions. Only the registers that are explicitly mentioned in the action may be changed -- all other registers must remain unchanged. (a) Clear the value in R2. AND R2, R2, #0 (b) Copy the value in R5 to R7. ADD R7, R5, #0 (c) Add the values in R3 and R6 to create an address, and store the value in R3 to memory at that address. (You may change R6, but only if you have to.) ADD R6, R6, R3 STR R3, R6, #0 (d) Without changing any other bits, clear the least significant bit of R1. AND R1, R1, xFFFE or AND R1, R1, #-2 (e) Without changing any other bits, set the least significant bit of R4 to 1. NOT R4, R4 or AND R4, R4, #-2 AND R4, R4, #-2 ADD R4, R4, #1 NOT R4, R4

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

View Full Document
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ECE 109-001 Name:____________________________________________ NC State University Exam 2(A): 5 November 2007 2 2. (20 points) Using the symbol table on the right, write the corresponding LC-3 machine language word (16 bits, binary) for each assembly language statement below. Assume in each case that the instruction/data word is located at address x4006 . If a translation cannot be performed with the information given, write ILLEGAL in the blank space. Assembly Language Machine Language ADD R6, R4, R4 __ 0001 110 100 000 100 _________________ BRnzp SCHRUTE __ 0000 111 111110000 __________________ LDR R2, SCRANTON __ illegal (wrong operands) ______________ AND R0, R1, 0x00FF __ illegal (imm. value too large) __________ LEA R5, PAPER __ illegal (offset too large) _______________ .FILL #-15 __ 1111111111110001 ___________________ AND R3, R6, #-3 __ 0101 011 110 1 11101 _________________ BRp MIFFLIN
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 7

exam2-a-fall07-soln - ECE 109-001 NC State University Exam...

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

View Full Document
Ask a homework question - tutors are online