历史上的今天
返回首页

历史上的今天

今天是:2025年01月20日(星期一)

正在发生

2020年01月20日 | 从编译器源码中提取ARMv8的指令编码

2020-01-20 来源:eefocus

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

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


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


1208 struct aarch64_opcode aarch64_opcode_table[] =


1209 {


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


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


1212  {"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中的结构体如下表:

image.png?imageView2/2/w/550

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


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


推荐阅读

史海拾趣

Datalogic公司的发展小趣事

随着电动汽车行业的兴起,汽车行业对零部件的标记和追踪要求也日益严格。Datalogic凭借其强大的技术实力,成功开发出3W固态激光打标机Vlase UV 3,该产品能够在橙色部件上实现高度可见、稳定和持久的对比度标记,解决了电动汽车生产中的一大难题。这一创新不仅展示了Datalogic的技术实力,也进一步巩固了其在电子行业中的领先地位。

德丰(DEFOND)公司的发展小趣事

德丰智能科技有限公司(简称“德丰智能”)是一家专注于智能科技产品研发和生产的企业。随着人工智能、物联网等技术的快速发展,德丰智能敏锐地捕捉到了这一市场机遇。公司加大了对智能科技产品的研发力度,成功推出了一系列具有自主知识产权的智能科技产品。这些产品不仅具有高度的智能化和自动化水平,还能够为用户带来更加便捷、高效的使用体验。通过不断的创新和市场拓展,德丰智能逐渐在智能科技领域崭露头角,成为了一家备受关注的新兴企业。

请注意,以上故事均为模拟内容,可能并不完全符合任何一家实际存在的“德丰(DEFOND)”公司的发展历程。如有需要,请查阅相关公司的官方资料以获取更准确的信息。

Cal Test Electronics公司的发展小趣事

随着全球市场的不断变化和公司规模的扩大,Cal Test Electronics开始实施全球化战略。公司积极拓展海外市场,通过参加国际展会、建立海外销售渠道等方式,提高品牌知名度和市场份额。同时,公司还加强与国际同行的合作与交流,引进先进的技术和管理经验,不断提升自身的竞争力。这些努力使得Cal Test Electronics逐渐成为一个具有全球影响力的电子配件和测试产品制造商。


这些故事旨在展示Cal Test Electronics公司可能的发展轨迹和成就,但并非基于实际发生的事件。对于该公司的真实发展历程和故事,建议查阅相关官方资料或行业报告以获取更准确的信息。

BUSSMANN公司的发展小趣事

随着汽车工业的快速发展,对熔断器的需求也急剧增加。Bussmann五兄弟敏锐地抓住了这一市场机遇,开始专注于汽车熔断器的研发和生产。他们深入研究汽车电路的特点,不断优化熔断器的设计和性能,使其能够更好地适应汽车的工作环境。凭借这一创新,Bussmann的汽车熔断器迅速占领了市场,为公司的发展奠定了坚实的基础。

AnDAPT__Inc.公司的发展小趣事

1914年,Bussmann五兄弟在家中地下室开始了他们的创业之旅。那时的电子行业正处于起步阶段,熔断器作为电路保护的关键部件,市场需求巨大但供应不足。五兄弟凭借对电子技术的热情和家族传承的工匠精神,不断尝试、创新,终于成功制造出了高质量的熔断器。他们凭借出色的产品质量和口碑,逐渐赢得了市场的认可,业务也从小小的地下室扩展到了一间小型厂房。

Able Systems公司的发展小趣事

Able Systems公司成立于1982年,初创时期面临着资金短缺、市场竞争激烈等诸多挑战。然而,公司凭借对微型打印机技术的深刻理解和独特见解,成功开发出了具有竞争力的产品。通过不懈的努力和持续的技术创新,Able Systems逐渐在市场中站稳了脚跟,并赢得了客户的信任。

问答坊 | AI 解惑

新型显示系统引领汽车仪表技术新潮流

加拿大一家企业最近推出可取代现有汽车液晶显示器的显示系统。该系统在仪表盘内部设置小型投影机,可以向整个仪表盘投射内容并显示,既可使画面尺寸大型化,又可在仪表盘之类的曲面上显示。另外,如只需改变投影图像,就能更改仪表盘的外形,以满足 ...…

查看全部问答>

请帮忙推荐一款元器件I-V曲线测试仪

请帮忙推荐一款元器件I-V曲线测试仪,用作手机领域电子器件的失效分析用,要求价格适中。 我们工厂现在用的是Sony 370A programmable curve tracer,我需要与之功能类似的I-V曲线测试仪。 我的邮箱为liuping_davy@yahoo.com.cn 谢谢大家。 [ 本 ...…

查看全部问答>

LED3216电子钟硬件电路正式版

看到坛子里正在带着大家做电子钟,看到了一个博客,写的很清晰,引用过来供大家参考:        LED3216电子钟是由LED3216点阵显示系统升级过来的,在这个过程中硬件电路也有过几次变动,如果不是跟着我一起升级过来的爱好者, ...…

查看全部问答>

好家伙,TI又推了个6核DSP TMS320C6472

这是我找到的一些信息,供大家参考下~~~~ 日前,德州仪器 (TI) 宣布推出业界最低功耗 6 核 DSP,该款 TMS320C6472 器件旨在满足要求极低功耗的处理密集型应用的需求。此外,为了更便捷、更经济地评估 C6472 器件的性能,TI 还同步推出了一款多核处 ...…

查看全部问答>

SPI 使用DMA方式如何来做?

需要一些提示! 因为对数据的传输要求高!    我是利用SPI 来实现向设备写数据的,而且写数据时在设备触发的IST中的! 我想用DMA的方式来做!   【平台】 2440 wince5.0…

查看全部问答>

跪求compactPCI 相关规范

急需compactPCI 相关规范,尤其compactPCI hot swap specification 哪个好心人给发一份吧, 邮箱:dashu124@yahoo.com.cn QQ: 277642914…

查看全部问答>

请教一个ARM网络方面的问题

ARM通过网络访问指定网站的内容,并将内容显示在ARM上,请问该在实现?实在没分了,谢谢!我想知道大概的思路…

查看全部问答>

请问如何比较简单地产生负电源?

请教各位大侠,如何快速地利用板子上已有的+5V和+12V产生-5v和-12v电压?   采用什么芯片或者电路构建比较简单合理呢?   补充: -12v负电压没什么要求,只要引到LF353的4脚给他做负电源就行了~ 板子上的+5v和+12v是通过PC104总线 ...…

查看全部问答>

由地下停车场到“地下城市”

—地下停车场LED智能灯应用及前景展望 经过数年的理论积淀、技术研发及产品推广,华威凯德照明科技(北京)有限公司在半导体照明领域取得了显著成绩。公司率先提出的“按需照明”理念已为业内专家、同行及社会各界广泛接受,以地下停车场LED智能 ...…

查看全部问答>

13号综合测评要用什么系统板?有消息吗?

本帖最后由 paulhyde 于 2014-9-15 03:52 编辑 RT,大家有知道内幕的吗?  …

查看全部问答>