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.
You will need to refer to the assembly language handouts and the LC-3b ISA on the course website.
Consider the following LC-3b assembly language program:
.ORIG x3000 AND R5, R5, #0 AND R3, R3, #0 ADD R3, R3, #8 LEA R0, B LDW R1, R0, #1 LDW R1, R1, #0 ADD R2, R1, #0 AGAIN ADD R2, R2, R2 ADD R3, R3, #-1 BRp AGAIN LDW R4, R0, #0 AND R1, R1, R4 NOT R1, R1 ADD R1, R1, #1 ADD R2, R2, R1 BRnp NO ADD R5, R5, #1 NO HALT B .FILL XFF00 A .FILL X4000 .END
The assembler creates a symbol table after the first pass. Show the contents of this symbol table.
What does this program do? (in less than 25 words)
When the programmer wrote this program, he/she did not take full advantage of the instructions provided by the LC-3b ISA. Therefore the program executes too many unnecessary instructions. Show what the programmer should have done to reduce the number of instructions executed by this program.
Consider the following LC-3b assembly language program.
.ORIG x4000 MAIN LEA R2,L0 JSRR R2 JSR L1 HALT ; L0 ADD R0,R0,#5 RET ; L1 ADD R1,R1,#5 RET
Assemble the above program. Show the LC-3b machine code for each instruction in the program as a hexadecimal number.
This program shows two ways to call a subroutine. One requires two instructions:
JSRR. The second requires only one instruction:
JSR. Both ways work
correctly in this example. Is it ever necessary to use
JSRR? If so, in what
Please go to the handouts section of the course web site, print and fill out the student information sheet, and turn it in with a recognizable recent photo of yourself on January 31st (the same day this problem set is due).