MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / aarch64_disassemble

Function aarch64_disassemble

arch/arm64/disassembler/format.c:477–602  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

475//-----------------------------------------------------------------------------
476
477int aarch64_disassemble(Instruction *instruction, char *buf, size_t buf_sz)
478{
479 char operandStrings[MAX_OPERANDS][130];
480 char tmpOperandString[128];
481 const char *operand = tmpOperandString;
482 if (instruction == NULL || buf_sz == 0 || buf == NULL)
483 return INVALID_ARGUMENTS;
484
485 memset(operandStrings, 0, sizeof(operandStrings));
486 const char *operation = get_operation(instruction);
487 if (operation == NULL)
488 return FAILED_TO_DISASSEMBLE_OPERATION;
489
490 for(int i=0; i<MAX_OPERANDS; i++)
491 memset(&(operandStrings[i][0]), 0, 128);
492
493 for(int i=0; i<MAX_OPERANDS && instruction->operands[i].operandClass != NONE; i++)
494 {
495 switch (instruction->operands[i].operandClass)
496 {
497 case CONDITION:
498 if (snprintf(tmpOperandString, sizeof(tmpOperandString), "%s",
499 get_condition((Condition)instruction->operands[i].cond)) >= sizeof(tmpOperandString))
500 return FAILED_TO_DISASSEMBLE_OPERAND;
501 operand = tmpOperandString;
502 break;
503 case FIMM32:
504 case IMM32:
505 case IMM64:
506 case LABEL:
507 case STR_IMM:
508 if (get_shifted_immediate(
509 &instruction->operands[i],
510 tmpOperandString,
511 sizeof(tmpOperandString),
512 instruction->operands[i].operandClass) != DISASM_SUCCESS)
513 return FAILED_TO_DISASSEMBLE_OPERAND;
514 operand = tmpOperandString;
515 break;
516 case REG:
517 if (get_register(
518 &instruction->operands[i],
519 0,
520 tmpOperandString,
521 sizeof(tmpOperandString)) != DISASM_SUCCESS)
522 return FAILED_TO_DISASSEMBLE_OPERAND;
523 operand = tmpOperandString;
524 break;
525 case SYS_REG:
526 operand = get_system_register_name(instruction->operands[i].sysreg);
527 if (operand == NULL)
528 {
529 return FAILED_TO_DISASSEMBLE_OPERAND;
530 }
531 break;
532 case MULTI_REG:
533 if (get_multireg_operand(
534 &instruction->operands[i],

Callers 2

disassembleFunction · 0.85
disassembleFunction · 0.85

Calls 11

get_shifted_immediateFunction · 0.85
get_multireg_operandFunction · 0.85
get_memory_operandFunction · 0.85
get_sme_tileFunction · 0.85
get_indexed_elementFunction · 0.85
get_accum_arrayFunction · 0.85
get_operationFunction · 0.70
get_conditionFunction · 0.70
get_registerFunction · 0.70
get_system_register_nameFunction · 0.70

Tested by 1

disassembleFunction · 0.68