Path: blob/master/libs/capstone/arch/AArch64/AArch64BaseInfo.c
4393 views
//===-- AArch64BaseInfo.cpp - AArch64 Base encoding information------------===//1//2// The LLVM Compiler Infrastructure3//4// This file is distributed under the University of Illinois Open Source5// License. See LICENSE.TXT for details.6//7//===----------------------------------------------------------------------===//8//9// This file provides basic encoding and assembly information for AArch64.10//11//===----------------------------------------------------------------------===//1213/* Capstone Disassembly Engine */14/* By Nguyen Anh Quynh <[email protected]>, 2013-2019 */1516#ifdef CAPSTONE_HAS_ARM641718#if defined (WIN32) || defined (WIN64) || defined (_WIN32) || defined (_WIN64)19#pragma warning(disable:4996) // disable MSVC's warning on strcpy()20#pragma warning(disable:28719) // disable MSVC's warning on strcpy()21#endif2223#include "../../utils.h"2425#include <stdio.h>26#include <stdlib.h>2728#include "AArch64BaseInfo.h"2930#include "AArch64GenSystemOperands.inc"3132// return a string representing the number X33// NOTE: result must be big enough to contain the data34static void utostr(uint64_t X, bool isNeg, char *result)35{36char Buffer[22];37char *BufPtr = Buffer + 21;3839Buffer[21] = '\0';40if (X == 0) *--BufPtr = '0'; // Handle special case...4142while (X) {43*--BufPtr = X % 10 + '0';44X /= 10;45}4647if (isNeg) *--BufPtr = '-'; // Add negative sign...4849// suppose that result is big enough50strncpy(result, BufPtr, sizeof(Buffer));51}5253// NOTE: result must be big enough to contain the result54void AArch64SysReg_genericRegisterString(uint32_t Bits, char *result)55{56// assert(Bits < 0x10000);57char Op0Str[32], Op1Str[32], CRnStr[32], CRmStr[32], Op2Str[32];58int dummy;59uint32_t Op0 = (Bits >> 14) & 0x3;60uint32_t Op1 = (Bits >> 11) & 0x7;61uint32_t CRn = (Bits >> 7) & 0xf;62uint32_t CRm = (Bits >> 3) & 0xf;63uint32_t Op2 = Bits & 0x7;6465utostr(Op0, false, Op0Str);66utostr(Op1, false, Op1Str);67utostr(Op2, false, Op2Str);68utostr(CRn, false, CRnStr);69utostr(CRm, false, CRmStr);7071dummy = cs_snprintf(result, 128, "s%s_%s_c%s_c%s_%s",72Op0Str, Op1Str, CRnStr, CRmStr, Op2Str);73(void)dummy;74}7576#endif777879