什么是" .S"后缀x86指令? [英] What is the ".s" suffix in x86 instructions?

查看:226
本文介绍了什么是" .S"后缀x86指令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我拆开使用 objdump的某些二进制文件的的.text 部分(既AT& T公司和Intel语法),我有时会看到一个 .S 后缀,例如说明: cmpb.s%BH,%CH sbbl.s%EDI,EDI% adcb.s%BL,DH%

When I disassemble the .text sections of some binaries using objdump (with both AT&T and Intel syntaxes), I sometimes see instructions with a .s suffix, for example: cmpb.s %bh,%ch, sbbl.s %edi,%edi, or adcb.s %bl,%dh.

.S 后缀是否有一个有效的/有用的意义(甚至还不如一个后缀),或者这是拆卸一些数据/填充的一个假象,好像它是一个指令序列?谢谢你。

Does the .s suffix have a valid/useful meaning (perhaps not even as a suffix), or is this an artefact of disassembling some data / padding as if it was a sequence of instructions? Thank you.

推荐答案

要了解 .S 后缀意味着什么,你需要了解的x86指令是如何连接codeD。如果我们把 ADC 作为一个例子,有一些操作数可以采取四种主要形式:

To understand what the .s suffix means, you need to understand how x86 instructions are encoded. If we take adc as an example, there are four main forms that the operands can take:


  1. 源操作数是立即,与目标操作数是累加寄存器。

  2. 源操作数是立即,且目标操作数是寄存器或内存位置

  3. 源操作数是一个寄存器,目标操作数是寄存器或内存位置。

  4. 源操作数是寄存器或内存位置,与目标操作数是寄存器。

和当然还有为不同的操作数大小的这些变体:8位,16位,32位等

And of course there are variants of these for the different operand sizes: 8-bit, 16-bit, 32-bit, etc.

当您的操作数中的一个是寄存器,另一个是一个存储器位置,这是显而易见的,其中汇编应该使用形式3和4,但是,当两个操作数都是寄存器,任一种形式是适用的。在 .S preFIX告诉构成使用汇编(或拆卸的情况下,显示您已使用的形式)。

When one of your operands is a register and the other is a memory location, it is obvious which of forms 3 and 4 the assembler should use, but when both operands are registers, either form is applicable. The .s prefix tells the assembler which form to use (or in the case of a disassembly, shows you which form has been used).

综观的具体例子 ADCB%BL,DH%,这两种方式也可以是带codeD如下:

Looking at the specific example of adcb %bl,%dh, the two ways it can be encoded are as follows:

10 de   adcb   %bl,%dh
12 f3   adcb.s %bl,%dh

第一个字节决定所使用的指令,我会回来以后的形式。第二个字节是什么是知道作为MODR / M字节,并指定寻址模式和寄存器所使用的操作数。所述MODR / M字节可以分成三个字段:mod(最显著2比特),REG(今后3)和R / M(最后3)

The first byte determines the form of the instruction used, which I'll get back to later. The second byte is what is know as a ModR/M byte and specifies the addressing mode and register operands that are used. The ModR/M byte can be split into three fields: Mod (the most significant 2 bits), REG (the next 3) and R/M (the last 3).

de: Mod=11, REG = 011, R/M = 110
f3: Mod=11, REG = 110, R/M = 011

的mod和R / M场共同决定了存储单元的有效地址,如果操作数之一是一个存储器位置,但是,当操作数仅仅是一个寄存器,mod字段被设置为11,和R / M是寄存器的值。该REG场显然只是重新presents其他寄存器。

The Mod and R/M fields together determine the effective address of the memory location if one of the operands is a memory location, but when that operand is just a register, the Mod field is set to 11, and R/M is the value of the register. The REG field obviously just represents the other register.

所以在字节的R / M字段保存 DH 注册,而REG领域持有在 BL 注册。而在 F3 字节的R / M字段保存 BL 注册,而REG领域持有 DH 注册。 (8位寄存器都设有codeD在该命令人,CL,DL,BL啊,数字0至7 CH,DH,BH)

So in the de byte, the R/M field holds the dh register, and the REG fields holds the bl register. And in the f3 byte, the R/M field holds the bl register, and the REG fields holds the dh register. (8-bit registers are encoded as the numbers 0 to 7 in the order al,cl,dl,bl,ah,ch,dh,bh)

再回到第一个字节中, 10 告诉我们要使用表单3编码,其中源操作数总是一个寄存器(​​即它来自REG场),与目标操作数是一个存储器位置或寄存器(即,它是由mod和R / M场确定)。在 12 告诉我们要使用表单4编码,其中操作数是其他方式 - 源操作数是由mod和R / M字段和目标操作数确定来自REG领域。

Getting back to the first byte, the 10 tells us to use the form 3 encoding, where the source operand is always a register (i.e. it comes from the REG field), and the destination operand is a memory location or register (i.e. it is determined by the Mod and R/M fields). The 12 tells us to use the form 4 encoding, where the operands are the other way around - the source operand is determined by the Mod and R/M fields and the destination operand comes from the REG field.

因此​​,该寄存器存储在MODR / M字节的位置被交换,并且该指令的第一个字节告诉我们它的操作数的存储位置。

So the the position the registers are stored in the ModR/M byte are swapped, and the first byte of the instruction tells us which operand is stored where.

这篇关于什么是" .S"后缀x86指令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆