operand order in x86 assembly language



order in x86 assembly language




ADD—Add





Opcode Instruction Op/En   64-bit Mode   Compat/Leg Mode Description
04 ib ADD AL, imm8 I Valid Valid Add imm8 to AL.
05 iw ADD AX, imm16 I Valid Valid Add imm16 to AX.
05 id ADD EAX, imm32 I Valid Valid Add imm32 to EAX.
REX.W + 05 id ADD RAX, imm32 I Valid N.E. Add imm32 sign-extended to 64-bits to RAX.


Description
Adds the destination operand (first operand) and the source operand (second operand) and then stores the result 
in the destination operand. The destination operand can be a register or a memory location; the source operand 
can be an immediate, a register, or a memory location. (However, two memory operands cannot be used in one 
instruction.) When an immediate value is used as an operand, it is sign-extended to the length of the destination 
operand format.
The ADD instruction performs integer addition. It evaluates the result for both signed and unsigned integer oper-
ands and sets the OF and CF flags to indicate a carry (overflow) in the signed or unsigned result, respectively. The 
SF flag indicates the sign of the signed result.


ADD  a  b  ==> a = a + b
a ==> destination operand / first operand
b ==> source operand  / second operand




CMP—Compare Two Operands



Opcode Instruction Op/En   64-bit Mode Compat/Leg Mode Description
3C ib CMP AL, imm8 I Valid Valid Compare imm8 with AL.
3D iw CMP AX, imm16 I Valid Valid Compare imm16 with AX.
3D id CMP EAX, imm32 I Valid Valid Compare imm32 with EAX.
REX.W + 3D id CMP RAX, imm32 I Valid N.E. Compare imm32 sign-extended to 64-bits with RAX.


Description
Compares the first source operand with the second source operand and sets the status flags in the EFLAGS register 
according to the results. The comparison is performed by subtracting the second operand from the first operand 
and then setting the status flags in the same manner as the SUB instruction. When an immediate value is used as 
an operand, it is sign-extended to the length of the first operand.


CMP a b ==> a - b
a ==> destination operand / first operand
b ==> source operand  / second operand


CMP  <==> SUB



SUB—Subtract



2C ib SUB AL, imm8 I Valid  Valid Subtract imm8 from AL.
2D iw SUB AX, imm16 I Valid  Valid Subtract imm16 from AX.
2D id SUB EAX, imm32 I Valid  Valid Subtract imm32 from EAX.
REX.W + 2D id SUB RAX, imm32 I Valid  N.E. Subtract imm32 sign-extended to 64-bits from RAX.


Description
Subtracts the second operand (source operand) from the first operand (destination operand) and stores the result 
in the destination operand. The destination operand can be a register or a memory location; the source operand 
can be an immediate, register, or memory location. (However, two memory operands cannot be used in one 
instruction.) When an immediate value is used as an operand, it is sign-extended to the length of the destination 
operand format.


SUB a  b ==> a = a - b


a ==> destination operand / first operand
b ==> source operand  / second operand
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值