35.3.1.8. INTEGER ARITHMETICAL ON X86




	(Add with Carry) =================
ADC	AL,imm8			14 	ib
ADC	AX,imm16		15 	iw
ADC	EAX,imm32		15	id
ADC	r/m8,imm8		80/2	ib
ADC	r/m16,imm16		81/2	iw
ADC	r/m32,imm32		81/2	id
ADC	r/m16,imm8		83/2	iw
ADC	r/m32,imm8		83/2	iw
ADC	r/m8,r8			10/r
ADC	r/m16,r16		11/r
ADC	r/m32,r32		11/r
ADC	r8,r/m8			12/r
ADC	r16,r/m16		13/r
ADC	r32,r/m32		13/r

	DEST <- DEST + SRC + CF



	(Add) ===========================
ADD	AL,imm8			04 	ib
ADD	AX,imm16		05 	iw
ADD	EAX,imm32		05	id
ADD	r/m8,imm8		80/0	ib
ADD	r/m16,imm16		81/0	iw
ADD	r/m32,imm32		81/0	id
ADD	r/m16,imm8		83/0	iw
ADD	r/m32,imm8		83/0	iw
ADD	r/m8,r8			00/r
ADD	r/m16,r16		01/r
ADD	r/m32,r32		01/r
ADD	r8,r/m8			02/r
ADD	r16,r/m16		03/r
ADD	r32,r/m32		03/r

	DEST <- DEST + SRC


	(Subtract) ========================
SUB	AL,imm8			2C 	ib
SUB	AX,imm16		2D 	iw
SUB	EAX,imm32		2D	id
SUB	r/m8,imm8		80/5	ib
SUB	r/m16,imm16		81/5	iw
SUB	r/m32,imm32		81/0	id
SUB	r/m16,imm8		83/5	iw
SUB	r/m32,imm8		83/5	iw
SUB	r/m8,r8			28/r
SUB	r/m16,r16		29/r
SUB	r/m32,r32		29/r
SUB	r8,r/m8			2A/r
SUB	r16,r/m16		2B/r
SUB	r32,r/m32		2B/r

	DEST <- DEST - SRC


	(Subtract wih borrow) ============
SBB	AL,imm8			2C 	ib
SBB	AX,imm16		2D 	iw
SBB	EAX,imm32		2D	id
SBB	r/m8,imm8		80/5	ib
SBB	r/m16,imm16		81/5	iw
SBB	r/m32,imm32		81/0	id
SBB	r/m16,imm8		83/5	iw
SBB	r/m32,imm8		83/5	iw
SBB	r/m8,r8			28/r
SBB	r/m16,r16		29/r
SBB	r/m32,r32		29/r
SBB	r8,r/m8			2A/r
SBB	r16,r/m16		2B/r
SBB	r32,r/m32		2B/r

	DEST <- DEST - (SRC + CF)


	(Decrement by 1) ===============
DEC	r/m8			FE/1
DEC	r/m16			FF/1
DEC	r/m32			FF/1
DEC	r16			48+rw
DEC	r32			48+rd
	
	DEST <- DEST - 1


	(Increment by 1) ==============
INC	r/m8			FE/0
INC	r/m16			FF/0
INC	r/m32			FF/0
INC	r16			40+rw
INC	r32			40+rd
	
	DEST <- DEST + 1


	(Unsigned Divide) ==================
DIV	r/m8			F6/6
DIV	r/m16			F7/6
DIV	r/m32			F7/6

	Quotient  <- Divident / Divisor			(UnSigned)
	Remainder <- Divident MOD Divisor		(UnSigned)
 	
	Divident Divisor  Quotient  Remainder
	AX	  r/m8	    AL	      AH
	DX:AX	  r/m16	    AX        DX
	EDX:EAX	  r/m32	    EAX       EDX


	
	(Signed Divide) ====================
IDIV	r/m8			F6/7
IDIV	r/m16			F7/7
IDIV	r/m32			F7/7

	Quotient  <- Divident / Divisor			(Signed)
	Remainder <- Divident MOD Divisor		(Signed)
 	
	Divident Divisor  Quotient  Remainder
	AX	  r/m8	    AL	      AH
	DX:AX	  r/m16	    AX        DX
	EDX:EAX	  r/m32	    EAX       EDX


	(Signed Multiply) ===================
IMUL	r/m8			F6/5
IMUL	r/m16			F7/5
IMUL	r/m32			F7/5
IMUL	r16,r/m16		0F AF /r
IMUL	r32,r/m32		0F AF /r
IMUL	r16,r/m16,imm8		6B /r ib
IMUL	r32,r/m32,imm8		6B /r ib
IMUL	r16,imm8		6B /r ib
IMUL	r32,imm8		6B /r ib
IMUL	r16,r/m16,imm16		69 /r iw
IMUL	r32,r/m32,imm32		69 /r id
IMUL	r16,imm16		69 /r iw 
IMUL	r32,imm32		69 /r id

	result <- multiplicand * multiplier


	(Unsigned Multiply) =================
MUL	r/m8			F6/4
MUL	r/m16			F7/4
MUL	r/m32			F7/4

	AX <-  AL * r/m8
    or
	DX:AX <- AX * r/m16
    or
	EDX:EAX <- EAX * r/m32



	(Negate) ============================
NEG	r/m8			F6/3
NEG	r/m16			F7/3
NEG	r/m32			F7/3

	if r/m = 0 then CF <- 0 else CF <- 1
	r/m <- 0 - r/m



Note:	FPU Enable to Load 64bit Integers as FP and Provide operations
on it. Because on Extended precension significand is 64bit too, this
scheme will be work.




Index Prev Next