Homework 5 for CSCI 255

This homework is based on Homework 5 for ECE 109.

Due date

This assignment is due in class Thursday, 2 April or to my office assistant in RH 215 by 4:30 pm on 2 April.

Problem 1

In this question encode the proper instructions in hexadecimal to achieve the task asked in the question. Each question can be done with only one intsruction

Part A

Encode in hex an instruction to load the contents of Memory at address x30FD into R3. The encoded instruction will be stored at memory location x3000.

Setup for Parts B and C

The following tables contain known memory and register contents.

RegisterValue
R00x0003
R10x4002
R20x0001
R30x0000
R40x0000
R50x0000
R60x1000
R70x0000
Memory AddressValue
0x30060x5000
0x30070x0004
0x30080x00FF
0x30090x5F00

Part B

Encode in hex an instruction that would load the contents of memory in location x4000 into R4. The encoded instruction will be stored at memory location x3001.

Part C

Encoded in hex an instruction that would store the value in R0 into memory location x5F00. The encoded instruction will be stored at memory location x3002.

Problem 2

This question tests your ability to understand the different types of addressing modes used in LC-3 load/store instructions.

Instruction sequence

In the program below assume all register are intially zero. The program begins running at memory location x3000. Assume the program runs until it encounters the HALT (TRAP x25) instruction. If an instruction stores a result into a register value, write down the result, the destination register, and the modified NZP bits for that instruction. Fill in the contents of the registers just before

Address Memory
contents
Result Register NZP
for destination register when appropriate
x30000010010000000100   
x30011110001000000010   
x30020110000001000000   
x30030000111000000010   
x30040011000000001000   
x30050000000000100111   
x30061010011111111101   
x30070000111000000001   
x30080000000000001011   
x30091001010010111111   
x300A0001010010000001   
x300B0001000010000000   
x300C1111000000100101   

Final Register Contents

What are the values of register R0, R10, R2, and R3 when the HALT is reached?