2012年11月份的资料,之前ARMv8手冊还没公布,我想办法从编译器的binutils中提取出了全部ARMv8指令的二进制编码,之前不能随便发,如今相当于解禁了^_^。

问题1:提取ARMv8的指令编码

答:ARMv8指令的opcode能够在支持ARMv8的编译器binutils中找到,该工具能在网上找到,见參考资料[1],或者在[1]中搜索aarch64_opcode_table。

为了说明指令编码细节。现将网页中部分内容摘录例如以下:


struct aarch64_opcode aarch64_opcode_table[] =

{

  /* Add/subtract (with carry).  */

  {"adc", 0x1a000000, 0x7fe0fc00, addsub_carry, 0, CORE, OP3 (Rd, Rn, Rm), QL_I3SAMER, F_SF},

p=jk/arm64/binutils.git;a=blob;f=opcodes/aarch64-tbl.h;h=d360b1406718257da86050f5b3a760cd02196250;hb=aarch64#l1212">  {"adcs", 0x3a000000, 0x7fe0fc00, addsub_carry, 0, CORE, OP3 (Rd, Rn, Rm), QL_I3SAMER, F_SF},

以上结构体中的每一项相应某条指令的操作码等信息。当中aarch64_opcode结构体(见參考文献[2])在。内容摘录例如以下:

structaarch64_opcode

{

/*The name of the mnemonic.  */

const char *name;

/*The opcode itself.  Those bits which willbe filled in with operands are zeroes. */

aarch64_insn opcode;

/*The opcode mask.  This is used by thedisassembler.  This is a mask containingones indicating those bits which must match the opcode field, and zeroesindicating those bits which need not match (and are presumably filled in byoperands).  */

aarch64_insn mask;

/*Instruction class.
 */

enum aarch64_insn_class iclass;

/*Enumerator identifier.  */

enum aarch64_op op;

/*Which architecture variant provides this instruction.  */

const aarch64_feature_set *avariant;

/*An array of operand codes.  Each code isan index into the operand table.  Theyappear in the order which the operands must appear in assembly code, and are terminatedby a zero.  */

enum aarch64_opnd operands[AARCH64_MAX_OPND_NUM];

/*A list of operand qualifier code sequence. Each operand qualifier code qualifies the corresponding operandcode.  Each operand qualifier sequencespecifies a valid opcode variant and related constraint on operands.  */

aarch64_opnd_qualifier_seq_t qualifiers_list[AARCH64_MAX_QLF_SEQ_NUM];

/*Flags providing information about this instruction */

uint32_t flags;

}

依照以上信息解释aarch64_opcode_table中的结构体例如以下表:

"adc",

0x1a000000

0x7fe0fc00

 addsub_carry,

 0

CORE

OP3 (Rd, Rn, Rm)

QL_I3SAMER, 

F_SF

助记符

操作码

操作码掩码

指令所属类

枚举器标识符

提供这样的指令的结构体变量

操作数编码数组

操作数限定符的代码序列列表

指令信息标志位

1:Aarch64-opc.c中有关于指令位域的定义。

const aarch64_field fields[] =

{

{  0,  0 },      /*NIL.  */

{  0,  4 },      /*cond2: condition in truly conditional-executed inst.  */

{  0,  4 },      /*nzcv: flag bit specifier, encoded in the "nzcv" field.  */

{  5,  5 },      /*defgh: d:e:f:g:h bits in AdvSIMD modified immediate.  */

{16,  3 },       /*abc: a:b:c bits in AdvSIMD modified immediate. */

{  5, 19 },       /* imm19: e.g. in CBZ. */

{  5, 19 },       /* immhi: e.g. in ADRP. */

{29,  2 },       /*immlo: e.g. in ADRP.  */

{22,  2 },       /*size: in most AdvSIMD and floating-point instructions.  */

{10,  2 },       /*vldst_size: size field in the AdvSIMD load/store inst.  */

{29,  1 },       /*op: in AdvSIMD modified immediate instructions. */

{30,  1 },       /*Q: in most AdvSIMD instructions.  */

{  0,  5 },      /*Rt: in load/store instructions.  */

{  0,  5 },      /*Rd: in many integer instructions.  */

{  5,  5 },      /*Rn: in many integer instructions.  */

{10,  5 },       /*Rt2: in load/store pair instructions.  */

{10,  5 },       /*Ra: in fp instructions.  */

{  5,  3 },      /*op2: in the system instructions.  */

{  8,  4 },      /*CRm: in the system instructions.  */

{12,  4 },       /*CRn: in the system instructions.  */

{16,  3 },       /*op1: in the system instructions.  */

{19,  2 },       /*op0: in the system instructions.  */

{10,  3 },       /*imm3: in add/sub extended reg instructions. */

{12,  4 },       /*cond: condition flags as a source operand. */

{12,  4 },       /*opcode: in advsimd load/store instructions. */

{12,  4 },       /*cmode: in advsimd modified immediate instructions.  */

{13,  3 },       /*asisdlso_opcode: opcode in advsimd ld/st single element.  */

{13,  2 },       /*len: in advsimd tbl/tbx instructions.  */

{16,  5 },       /*Rm: in ld/st reg offset and some integer inst. */

{16,  5 },       /*Rs: in load/store exclusive instructions. */

{13,  3 },       /*option: in ld/st reg offset + add/sub extended reg inst.  */

{12,  1 },       /*S: in load/store reg offset instructions. */

{21,  2 },       /*hw: in move wide constant instructions. */

{22,  2 },       /*opc: in load/store reg offset instructions. */

{23,  1 },       /*opc1: in load/store reg offset instructions. */

{22,  2 },       /*shift: in add/sub reg/imm shifted instructions. */

{22,  2 },       /*type: floating point type field in fp data inst.  */

{30,  2 },       /*ldst_size: size field in ld/st reg offset inst. */

{10,  6 },       /*imm6: in add/sub reg shifted instructions. */

{11,  4 },       /*imm4: in advsimd ext and advsimd ins instructions.  */

{16,  5 },       /*imm5: in conditional compare (immediate) instructions.  */

{15,  7 },       /*imm7: in load/store pair pre/post index instructions.  */

{13,  8 },       /*imm8: in floating-point scalar move immediate inst.  */

{12,  9 },       /*imm9: in load/store pre/post index instructions.  */

{10, 12 },         /* imm12: in ld/stunsigned imm or add/sub shifted inst.  */

{  5, 14 },       /* imm14: in test bit and branch instructions.  */

{  5, 16 },       /* imm16: in exception instructions.  */

{  0, 26 },       /* imm26: in unconditional branch instructions.  */

{ 10, 6 },       /* imms: in bitfield andlogical immediate instructions.  */

{16,  6 },       /*immr: in bitfield and logical immediate instructions.  */

{16,  3 },       /*immb: in advsimd shift by immediate instructions.  */

{19,  4 },       /*immh: in advsimd shift by immediate instructions.  */

{22,  1 },       /*N: in logical (immediate) instructions. */

{11,  1 },       /*index: in ld/st inst deciding the pre/post-index.  */

{24,  1 },       /*index2: in ld/st pair inst deciding the pre/post-index.  */

{31,  1 },       /*sf: in integer data processing instructions. */

{11,  1 },       /*H: in advsimd scalar x indexed element instructions.  */

{21,  1 },       /*L: in advsimd scalar x indexed element instructions.  */

{20,  1 },       /*M: in advsimd scalar x indexed element instructions.  */

{31,  1 },       /*b5: in the test bit and branch instructions. */

{19,  5 },       /*b40: in the test bit and branch instructions. */

{10,  6 },       /*scale: in the fixed-point scalar to fp converting inst.  */

};

2、函数aarch64_opcode_encode用于将操作数插入opcode中

參考资料

[1] ARMv8的编译器binutils,结构体aarch64_opcode_table定义见line 1208

p=jk/arm64/binutils.git;a=blob;f=opcodes/aarch64-tbl.h;h=d360b1406718257da86050f5b3a760cd02196250;hb=aarch64">http://kernel.ubuntu.com/git?p=jk/arm64/binutils.git;a=blob;f=opcodes/aarch64-tbl.h;h=d360b1406718257da86050f5b3a760cd02196250;hb=aarch64

[2] 结构体aarch64_opcode定义,line451

http://kernel.ubuntu.com/git?p=jk/arm64/binutils.git;a=blob;f=include/opcode/aarch64.h;h=98529954ea098349eb16572d4915f4edbd2e7b5d;hb=aarch64

[3] 《ARMv8 InstructionSet Overview 》page11

从编译器源代码中提取ARMv8的指令编码的更多相关文章

  1. 使用Python从PDF文件中提取数据

    前言 数据是数据科学中任何分析的关键,大多数分析中最常用的数据集类型是存储在逗号分隔值(csv)表中的干净数据.然而,由于可移植文档格式(pdf)文件是最常用的文件格式之一,因此每个数据科学家都应该了 ...

  2. [数据科学] 从csv, xls文件中提取数据

    在python语言中,用丰富的函数库来从文件中提取数据,这篇博客讲解怎么从csv, xls文件中得到想要的数据. 点击下载数据文件http://seanlahman.com/files/databas ...

  3. 如何使用免费PDF控件从PDF文档中提取文本和图片

             如何使用免费PDF控件从PDF文档中提取文本和图片 概要 现在手头的项目有一个需求是从PDF文档中提取文本和图片,我以前也使用过像iTextSharp, PDFBox 这些免费的PD ...

  4. SQL Server 检测到基于一致性的逻辑 I/O 错误 校验和不正确 ||尝试在数据库 5 中提取逻辑页 (1:1640) 失败

    use test go ALTER DATABASE test SET SINGLE_USER DBCC CHECKDB (test, repair_allow_data_loss) with NO_ ...

  5. JavaScript中,提取子字符串方法:Slice、Substring、Substr的比较。

    在JavaScript中,提取子字符串主要是通过 Slice.Substring.Substr 三个方法之一. // slice // 语法: string.slice(beginSlice [, e ...

  6. 通过ABAP的标准功能,寻找源代码中的字符串

    程序名称: *ABAP_SOURCE_SCAN 查找 作用:通过这个标准程序,可以在系统的源代码中进行字符串的查找!

  7. swfdump——从内存中提取swf的工具

    刚刚整理代码时发现以前写的从进程的内存镜像中提取swf文件的工具,现在分享出来,希望能帮到有需要的朋友.这个小工具是命令行使用,没有界面,可以很方便的从指定进程中(比如浏览器,swf播放器等等),按s ...

  8. 从jsTree演示代码中提取的在线文件查看

    从jsTree演示代码中提取的在线文件查看 jsTree 请参考:https://www.jstree.com/ 效果如下: 代码下载:http://files.cnblogs.com/files/z ...

  9. 在excel单元格中提取信息

    平时在excel中处理数据的时候,肯定会遇到在单元格提取信息的情况,比如在地址中提取省.市.地区等,如果数据源内容规整的话,可以直接使用left().right().mid()等函数直接提取,但是大多 ...

随机推荐

  1. CAD绘制固定圆形云线标注(网页吧)

    js中实现代码说明: function DoCloudCircleCommentFix() { var comment = mxOcx.NewEntity("IMxDrawComment&q ...

  2. CAD参数绘制固定批注(网页版)

    js中实现代码说明: 自定义实体绘制函数 function ExplodeFun(pCustomEntity, pWorldDraw, txt) { var sGuid = pCustomEntity ...

  3. 浅谈JS之text/javascript和application/javascript

    问题描述: JS在IE8以下浏览器运行异常 代码: <script>标签是这样子写的: <script type="application/javascript" ...

  4. std::function和std::bind详解

    原文:https://blog.csdn.net/xiaoyink/article/details/79348806

  5. [Python3网络爬虫开发实战] 3.2.2-高级用法

    在前一节中,我们了解了requests的基本用法,如基本的GET.POST请求以及Response对象.本节中,我们再来了解下requests的一些高级用法,如文件上传.cookie设置.代理设置等. ...

  6. 零基础入门学习Python(34)--丰富的else语句及简洁的with语句

    知识点 else语句的用法: 1)配合if语句 if a>b: print(a) else: print(b) 2)配合while和for循环 只在循环完成后才执行,如果循环中执行使用到brea ...

  7. axios增加的自定义header,后端request取不到

    1.拦截器配置 <!--拦截器--> <mvc:interceptors> <!-- web端增加头部接口 --> <mvc:interceptor> ...

  8. 如何判断CPU、内存、磁盘的性能瓶颈?

    1.如何判断CPU.内存.磁盘的瓶颈? CPU瓶颈1) 查看CPU利用率.建议CPU指标如下 a) User Time:65%-70% b) System Time:30%-35% c) Idle:0 ...

  9. postman工具的应用实战(二)

    在接口测试工具中,最好的应该是soapui,jmeter,postman,但是soapui需要安装和破解,当然也是有破解版的,但是不够灵活,jmeter工具 做接口测试还是性能测试,功能测试,都是一个 ...

  10. Eclipse调试相关

    Eclipse调试相关 F5 step into就是单步执行,遇到子函数就进入并且继续单步执行. F6 step over是在单步执行时,在函数内遇到子函数时不会进入子函数内单步执行,而是将子函数整个 ...