C programming using putty - need help for project
my program only needs to handle the following MIPS instructions: add, addi, addiu, addu, beq, bgez, bgtz, blez, bltz, bne, j, jal, jalr, jr, lb, lui, lw, mul, nop, ori, sb, sll, slt, sra, sub, sw, syscall, xor, and xori.
for each of the machine instructions my program should determine what MIPS instruction it is, and print that out on a separate line together with its address and machine code.
so basically i got this project where i need to design a program that reads in hexadecimal values (eg. 8fa40000 27a50004 24a6000) using a text file and outputs something like this:
[0x00400000] 0x8fa40000 lw
[0x00400004] 0x27a50004 addiu
[0x00400008] 0x24a60004 addiu
(sample output)
showing the machine address, machine instruction and the opcode of the instruction, with no additional whitespace.
to do all this, i gotta to decode some aspects of MIPS instructions and keep track of the current address. specifically, i need to:
- keep track of the current location. i assume that the first instruction will be at address 0x00400000 and each further instruction will be four bytes later.
- determine the opcode of each instruction.
so by the end i need to carefully separate the opcodes into classes, and create code to determine the opcode of any given instruction.
my problem is, i don't even know how to get started. it would be great if you guys could help me out, thanks =)