CO-Assignment-3
Suppose a 32-bit instruction takes the following format: (10 points)
If there are 225 opcodes and 120 general purpose registers
- What is the minimum number of bits required to represent the OPCODE? Explain why. (2 points)
minimun number of bits to represent the opcode: 8 bits There are 225 opcodes
- What is the minimum number of bits required to represent the Destination Register (DR)? Explain why. (2 points)
minimun number of bits to represent the : 7 bits There are 120 General purpose registers
- What is maximum number of UNUSED bits in the instruction encoding? Explain why. (2 points)
opcode: 8 bits DR: 7 bits SR1: 7 bits SR2: 7 bits
Unused bits: 32-8-21= 3 bits
- Suppose the address space contains
memory locations and the addressability is 32 bits. How many bytes can the memory store in total?
There are
- How many address lines are necessary? How many data lines are necessary?
32 address lines are necessary 32 data lines are necessary
The LC-3 does not have an opcode for the logical function OR. That is, there is no instruction in the LC-3 ISA that performs the OR operation. However, we can write a sequence of instructions to implement the OR operation. The four instruction sequence below performs the OR of the contents of register 1 and register 2 and puts the result in register 3. Fill in the two missing instructions so that the four instruction sequence will do the job.
(1): 1001 100 001 111111 (2): 1001 101 010 111111
Address X3010: 1110 0110 0011 1111 Address X3011: 0110 1000 1100 0000 Address X3012: 0110 1101 0000 0000
- Explain what each instruction does. (6 points)
In the first instruction:
In the second instruction:
In the third instruction:
- What is that value to be loaded into R6? (2 points)
- We could replace the three-instruction sequence with a single instruction. What is it? Write the instruction in binary. (2 points)
Suppose the following LC-3 program is loaded into memory starting at location x30FF: (12 points)
- Explain what each instruction does. (10 points)
x30FF 1110 001 00000001
X30FF: Load x3100 to
- If the program is executed, what is the value in R2 at the end of execution? (2 points)
- Construct the symbol table for the following LC-3 assembly language program. (10 points)
AGAIN x3002 ASCII x3009 NEG x300A DSR x300B DDR x300C
- Assemble it into binary machine code line by line by hand. (30 points)
.ORIG 0011 0000 0000 0000 x3000 0010 0000 0000 1000 x3001 0010 0010 0000 1000 x3002 1010 0100 0000 1000 x3003 0000 0111 1111 1110 x3004 1011 0000 0000 0111 x3005 0001 0000 0010 0001 x3006 0001 0100 0000 0001 x3007 0000 1011 1111 1010 x3008 1111 0000 0010 0101 x3009 0000 0000 0100 0001 x300A 1111 1111 1011 0110 x300B 1111 1110 0000 0100 x300C 1111 1110 0000 0110
- What does the program do? (10 points)
It print “ABCDEFGHI” on the console.