





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Main points of this past exam are: Minimum Number, Binary Representation, Complement Representation, Bits Needed, Represent Decimal, Unsigned Numbers, Treated
Typology: Exams
1 / 9
This page cannot be seen from the preview
Don't miss anything!






Problem 1 10 points _______________________________
Problem 2 15 points _______________________________
Problem 3 15 points _______________________________
Problem 4 15 points _______________________________
Problem 5 25 points _______________________________
Problem 6 20 points _______________________________
Total 100 points _______________________________
Name:
Friday Section Time:
Problem 1 (10 points): Binary Representation
Part A (5 points): What is the minimum number of bits needed to represent decimal 64 in binary using 2’s complement representation?
Part B (5 points): Given two 6-bit inputs A, and B, where A = x30 and B = x12. If C is a 6-bit output from an adder, where C = A + B, answer the following questions:
Assuming that A, B, and C are treated as unsigned numbers, is C a valid result? If not, in ten (10) words or less explain why not. If yes, write the value of C in decimal.
Assuming that A, B, and C are treated as 2’s complement numbers, is C a valid result? If not, in ten (10) words or less explain why not. If yes, write the value of C in decimal.
Problem 3 (15 points): Memory
Problem 4 (15 points): LC-3 ISA
Part A (5 points): You have been given a rather large library of code to use in a project, the main program must immediately call a function that starts at memory location x8000. Using one or more LC-3 instructions, create a program that calls this function. You must provide your solution in machine code.
(Hint: The NOT instruction might be useful)
Instruction
__________|_______________________________ ; x
__________|_______________________________ ; x
__________|_______________________________ ; x
__________|_______________________________ ; x
1111 0000 00011001 ; x
0111 1111 1111 1111 ; x
Part B (5 points): The following code is found at x8000, which is supposed to continually compare two numbers that were loaded into memory until both are equal. Assume that the contents of x8006 and x8007 may change at any time (this can be done using an interrupt service routine which will be covered later in the semester so do not worry about it).
Unfortunately, there is a problem with the code and it does not work. Fix it. There are several bugs in the code.
0010 001 000000101 ; x 1010 010 000000101 ; x 1001 001 001 111111 ; x 0001 001 001 1 00001 ; x 0001 001 001 1 00 010 ; x 0000 111 111111010 ; x
Part C (5 points): For the program given in Part A above, create the symbol table created by the assembler when generating the machine code. (5 points)
Part D (5 points): To multiply a number (stored in memory x4000) by 9, you could add a number repetitively 8 times (8 addition operations). Complete the program below such that only 4 addition instructions are needed to compute the product. Hint: 9x = (8x + x).
.ORIG x LDI R0, DATA AND R1, R1, #
DATA .FILL x RESULT .FILL x
*****Part E** (5 points): Write an LC-3 program that contains more store instructions than load instructions, but causes the LC-3 to read from memory more often than write to memory. A very short program suffices.
Problem 6 (20 points): Code Optimization
For this problem, consider the following piece of LC-3 Assembly code:
.ORIG x AND R3, R3, # AND R4, R4, # LD R0, START LDR R1, R0, #
BRp LOOP
START .FILL x RESULT .FILL x
Part A (10 points): In simple terms, what does this code do? Hint: Recall what you have worked on in Programming Studio
Part B (10 points): Your job is to optimize this code so that it runs as fast as possible. You can do this by reducing the number of instructions in the LOOP section of the code. Provide your solution to the right of the code above.