You are encouraged to work on the problem set in groups and turn in one problem set for the entire group. Remember to put all your names on the solution sheet. Also remember to put the name of the TA in whose discussion section you would like the problem set turned back to you.
If a computer has a 16-bit MAR and a 32-bit MDR:
We would like to have an instruction that does nothing. Many ISAs actually have an opcode devoted to doing nothing. It is usually called NOP, for NO OPERATION. The instruction is fetched, decoded and executed. The execution phase is to do nothing! Which of the following three instructions could be used for NOP and have the program still work correctly?
What does the ADD instruction do that the others do not do?
Which of the two algorithms for multiplying two numbers is preferable and why?
4 * 48 = 4 + 4 + 4 + 4 + ... + 4 or 48 + 48 +48 +48?
The LC-3 does not have an instruction to perform an OR. Write a LC-3 machine language program segment that takes the values in R1 and R2 and stores the OR of the two operands (R1 OR R2) in R3.
How many times does the LC-3 make a read or write request to memory during the processing of the LD instruction? Answer the same question for the LDR, LDI, and LEA instructions. Processing includes all phases of the instruction cycle.
An LDR instruction, located at x3200, uses R4 as its base register. The value currently in R4 is x4011. What is the largest address that this instruction can load from? Suppose we redefine the LDR offset to be zero-extended, rather that sign-extended. Then what would be the largest address that this instruction could load from? With the new definition, what would be the smallest address that this instruction could load from?
The following table shows a part of the LC-3s memory:
|0011 0001 0000 0000||1001 001 001 111111|
|0011 0001 0000 0001||0001 010 000 000 001|
|0011 0001 0000 0010||1001 010 010 111111|
|0011 0001 0000 0011||0000 010 111111100|
State what is known about R1 and R0 if the conditional branch redirects control to location x3100.
The following LC-3 Machine Language program is supposed to multiply the contents of R1 with R2 and store the result in R3. The program assumes that both R1 and R2 contain positive integers. However, there is an error in the program.
|x3000:||0101 0110 1110 0000|
|0001 0110 1100 0010|
|0001 0010 0111 1111|
|0000 0111 1111 1101|
|1111 0000 0010 0101|
Assume a sequence of nonnegative integers is stored in consecutive memory locations, one integer per memory location, starting at location x4000. Each integer has a value between 0 and 30,000 (decimal). The sequence terminates with the value -1 (i.e., xFFFF).
a. Create the symbol table entries generated by the assembler when translating the following routine into machine code:
.ORIG x3000 AND R4, R4, #0 AND R3, R3, #0 LD R0, NUMBERS LOOP LDR R1, R0, #0 NOT R2, R1 BRz DONE AND R2, R1, #1 BRz L1 ADD R4, R4, #1 BRnzp NEXT L1 ADD R3, R3, #1 NEXT ADD R0, R0, #1 BRnzp LOOP DONE TRAP x25 NUMBERS .FILL x4000 .END
b. What does the above program do?
Draw a flow chart for the following problem. It should be as specific as possible, similar to Figure 6.3 (e) page 161.
You are given 16 numbers stored in memory from location x3100 to x310F. Your program should take each number and left shift (not rotate) it until the most significant bit becomes 1, and then store this result back in the same location. This action is very useful in floating point processing, it can be used to normalize a result.
If the original contents of memory location x3100 was 0000 1010 0000 0011, then your program should store 1010 0000 0011 0000 in x3100.
If the original contents of memory location x3101 was 1111 0000 1111 0000, then your program should store 1111 0000 1111 0000 in x3101
Hint: You do not know the number of times you have to left shift each number. Think about how to decide that.
Note: You can assume that the numbers stored in memory locations x3100 to x310F will not be zero.
You are required to make the flowchart only!