MCPcopy Create free account
hub / github.com/MJx0/KittyMemoryEx / decodeInsnType

Function decodeInsnType

KittyMemoryEx/KittyAsm.cpp:31–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29namespace KittyArm32
30{
31 EKittyInsnTypeArm32 decodeInsnType(uint32_t instr)
32 {
33 if ((instr & 0x0C000000) == 0x00000000)
34 {
35 if ((instr & 0x01E00000) == 0x00800000)
36 return bits(instr, 19, 16) == 15 ? EKittyInsnTypeArm32::ADR : EKittyInsnTypeArm32::ADD;
37
38 if ((instr & 0x01E00000) == 0x00400000)
39 return bits(instr, 19, 16) == 15 ? EKittyInsnTypeArm32::ADR : EKittyInsnTypeArm32::SUB;
40
41 if ((instr & 0x01E00000) == 0x01A00000)
42 return EKittyInsnTypeArm32::MOV;
43 }
44
45 if ((instr & 0x0FF00000) == 0x02800000)
46 return EKittyInsnTypeArm32::LDR_LITERAL;
47
48 if ((instr & 0x0C500000) == 0x04100000)
49 return bits(instr, 19, 16) == 15 ? EKittyInsnTypeArm32::LDR_LITERAL : EKittyInsnTypeArm32::LDR;
50
51 if ((instr & 0x0C500000) == 0x04000000)
52 return EKittyInsnTypeArm32::STR;
53
54 if ((instr & 0x0C500000) == 0x04500000)
55 return bits(instr, 19, 16) == 15 ? EKittyInsnTypeArm32::LDR_LITERAL : EKittyInsnTypeArm32::LDRB;
56
57 if ((instr & 0x0C500000) == 0x04400000)
58 return EKittyInsnTypeArm32::STRB;
59
60 if ((instr & 0x0F1000F0) == 0x011000B0)
61 return EKittyInsnTypeArm32::LDRH;
62
63 if ((instr & 0x0F1000F0) == 0x010000B0)
64 return EKittyInsnTypeArm32::STRH;
65
66 if ((instr & 0x0F1000F0) == 0x011000D0)
67 return EKittyInsnTypeArm32::LDRSB;
68
69 if ((instr & 0x0F1000F0) == 0x011000F0)
70 return EKittyInsnTypeArm32::LDRSH;
71
72 if ((instr & 0x0F000000) == 0x0A000000)
73 return bits(instr, 31, 28) == 0xE ? EKittyInsnTypeArm32::B : EKittyInsnTypeArm32::B_COND;
74
75 if ((instr & 0x0F000000) == 0x0B000000)
76 return EKittyInsnTypeArm32::BL;
77
78 return EKittyInsnTypeArm32::UNKNOWN;
79 }
80
81 KittyInsnArm32 decodeInsn(uint32_t instr, uint32_t address)
82 {

Callers 1

decodeInsnFunction · 0.85

Calls 1

bitsFunction · 0.85

Tested by

no test coverage detected