Question: 1 . Write a C program that decodes an input machine code. Your program should be able to decode the R , I, S ,
Write a C program that decodes an input machine code. Your program should be able to decode the R I, S SB and UJ type instructions listed below. We will only test the following instructions.
add addi
and andi
beq bge
blt bne
jal jalr
lb lh
lw
or ori
sb sh
sll slli
slt slti
sltiu sltu
sra srai
srl srli
sub sw
xor xori
When the program is started, your program will print Enter an instruction: and receive one bit machine code from user. Then, the program will decode the machine code and print the information type and values of individual fields of the instruction format of the instruction. The following is the example execution of the program. The program must produce the following sample results in the exact same format.
Example :
Enter an instruction:
Instruction Type: R
Operation: add
Rs: x
Rs: x
Rd: x
Funct:
Funct:
Example :
Enter an instruction:
Instruction Type : I
Operation: andi
Rs: x
Rd: x
Immediate: or xA
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
