Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int GetType(unsigned int ins)
- {
- struct ins_format instruction;
- memset(&instruction, 0, 4);
- memcpy(&instruction, &ins, 4);
- if(instruction.b26 == 0 && instruction.b27 == 0)
- {
- if(instruction.b25 == 1)
- {
- puts("Data processing, immediate value");
- return INS_DATA_PROCESSING;
- }
- else if(instruction.b25 == 0)
- {
- if(instruction.b4 == 1 && instruction.b5 == 0 && instruction.b6 == 0 && instruction.b7 == 1)
- {
- if(instruction.b24 == 0)
- {
- // multiply
- if(instruction.b23 == 1)
- {
- puts("Long multiply");
- return INS_MULTIPLY_LONG;
- }
- else
- {
- puts("Multiply");
- return INS_MULTIPLY;
- }
- }
- else
- {
- puts("Swap");
- return INS_SWAP;
- }
- }
- else
- {
- if(instruction.b22 == 0 && instruction.b7 == 1 && instruction.b4 == 1)
- {
- puts("Halfword Transfer Reg Off");
- return INS_HALFWORD_XFER_REG;
- }
- else if(instruction.b22 == 1 && instruction.b7 == 1 && instruction.b4 == 1)
- {
- puts("Halfword Transfer Imm Off");
- return INS_HALFWORD_XFER_IMM;
- }
- else
- {
- puts("Data processing, register");
- return INS_DATA_PROCESSING;
- }
- }
- }
- if(instruction.b24 == 1)
- {
- if(instruction.b23 == 0 && instruction.b22 == 0 && instruction.b21 == 1 && instruction.b20 == 0)
- {
- puts("Branch exchange");
- return INS_BRANCH_EXCHANGE;
- }
- }
- return 0;
- }
- else if(instruction.b26 == 1 && instruction.b27 == 1)
- {
- if(instruction.b25 == 0)
- {
- puts("Coprocessor data transfer");
- return INS_COPROCESSOR_DATA_XFER;
- }
- else
- {
- if(instruction.b4 == 0)
- {
- puts("Coprocessor data operation");
- return INS_COPROCESSOR_DATA_OP;
- }
- else
- {
- puts("Coprocessor register transfer");
- return INS_COPROCESSOR_REG_XFER;
- }
- }
- if(instruction.b24 == 1 && instruction.b25 == 1)
- {
- puts("Software interrupt");
- return INS_SOFTWARE_INTERRUPT;
- }
- return 0;
- }
- else if(instruction.b26 == 0 && instruction.b27 == 1)
- {
- if(instruction.b25 == 1)
- {
- puts("Branch");
- return INS_BRANCH;
- }
- else
- {
- puts("Load/Store multiple");
- return INS_STORELOAD_MULT;
- }
- }
- else if(instruction.b26 == 1 && instruction.b27 == 0)
- {
- if(instruction.b25 == 1)
- {
- puts("Load/Store immediate value");
- return INS_STORELOAD_BYTEWORD;
- }
- else
- {
- puts("Load/Store register");
- return INS_STORELOAD_BYTEWORD;
- }
- }
- else
- {
- puts("Unknown");
- return INS_UNKNOWN;
- }
- return INS_UNKNOWN;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement