Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the order of source operands in AT&T syntax compared to Intel syntax?

The Intel ISA reference documentation for this instruction is clear:

VPBLENDVB xmm1, xmm2, xmm3/m128, xmm4

Select byte values from xmm2 and xmm3/m128 using mask bits in the specified mask register, xmm4, and store the values into xmm1.

xmm1 is the destination, xmm2/3/4 are source operands

So what does this become using AT&T syntax? We know that the destination register must be last, but what is the order of source operands?

vpblendvb $xmm2, $xmm3, $xmm4, $xmm1

or

vpblendvb $xmm4, $xmm3, $xmm2, $xmm1

or something else?

like image 947
biscuits Avatar asked Sep 25 '11 20:09

biscuits


People also ask

What are the sources of operand?

When an instruction requires two operands, the first operand is generally the destination, which contains data in a register or memory location and the second operand is the source. Source contains either the data to be delivered (immediate addressing) or the address (in register or memory) of the data.

What is source operand reference?

Source operand reference: Source Operand reference are the inputs for the process and it will be one or more than one operation. Result operand reference: Result Operand Reference produces a result. Next instruction reference: Next instruction reference tells the processor where to send the next instruction.

What are the three types of operands in x86?

Operands can be immediate (that is, constant expressions that evaluate to an inline value), register (a value in the processor number registers), or memory (a value stored in memory).

What are the operands in assembly language?

Each assembly language statement is split into an opcode and an operand . The opcode is the instruction that is executed by the CPU and the operand is the data or memory location used to execute that instruction.


1 Answers

Assembling (note GAS uses % instead of $ to denote registers) the following:

vpblendvb %xmm4, %xmm3, %xmm2, %xmm1

with the GNU assembler (version 2.21.0.20110327 on x86_64 2.6.38 linux) and then disassembling yields:

$ objdump -d a.out
    0:    c4 e3 69 4c cb 40     vpblendvb %xmm4,%xmm3,%xmm2,%xmm1

in intel syntax (as the manual shows):

$ objdump -d -M intel a.out
    0:    c4 e3 69 4c cb 40     vpblendvb xmm1,xmm2,xmm3,xmm4

So it looks like the order of all the arguments is reversed.

like image 119
user786653 Avatar answered Sep 27 '22 21:09

user786653