blob: 99d8bba0721dce1d19ca60dc820f38752f398e14 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#include "decode.h"
#include "feature_flags.h"
int decode_spec(context* ctx, Instruction* dec); // from decode0.cpp
int decode_scratchpad(context* ctx, Instruction* dec); // from decode_scratchpad.c
int aarch64_decompose(uint32_t instructionValue, Instruction* instr, uint64_t address)
{
context ctx = {0};
ctx.halted = 1; // enable disassembly of exception instructions like DCPS1
ctx.insword = instructionValue;
ctx.address = address;
ARCH_FEATURES_ENABLE_ALL(ctx.decode_features);
ARCH_FEATURES_ENABLE_ALL(ctx.pcode_features);
ctx.EDSCR_HDE = 1;
/* have the spec-generated code populate all the pcode variables */
int rc = decode_spec(&ctx, instr);
if (rc != DECODE_STATUS_OK)
{
/* exceptional cases where we accept a non-OK decode status */
if (rc == DECODE_STATUS_END_OF_INSTRUCTION && instr->encoding == ENC_HINT_HM_HINTS)
{
while (0)
;
}
/* no exception! fail! */
else
return rc;
}
/* if UDF encoding, return undefined */
// if(instr->encoding == ENC_UDF_ONLY_PERM_UNDEF)
// return DECODE_STATUS_UNDEFINED;
/* convert the pcode variables to list of operands, etc. */
return decode_scratchpad(&ctx, instr);
}
|