|
SUB -- Integer Subtraction
Opcode | Instruction | Clocks |
Description | Example |
2C ib | subb imm8,al | 2 |
Subtract immediate byte from AL | subb $0x7f,%al |
2D iw | subw imm16,ax | 2 |
Subtract immediate word from AX | subw $0x7fff,%ax |
2D id | subl imm32,eax | 2 |
Subtract immediate dword from EAX | subl $0x7fffffff,%eax |
80 /5 ib | subb imm8,r/m8 | 2/7 |
Subtract immediate byte from r/m byte | subb $0x7f,%dl
subb $0x7f,(%ebx,1)
subb $0x7f,m8(%ebx,1)
subb $0x7f,m8(%ebx,%ebp,1) |
81 /5 iw | subw imm16,r/m16 | 2/7 |
Subtract immediate word from r/m word | subw $0x7fff,%cx
subw $0x7fff,(%ebx,1)
subw $0x7fff,(%ebx,2)
subw $0x7fff,(%ebx,%ebp,1) |
81 /5 id | subl imm32,r/m32 | 2/7 |
Subtract immediate dword from r/m dword | subl $0x7fffffff,%ecx
subl $0x7fffffff,(%ebx,2)
subl $0x7fffffff,(%ebx,4)
subl $0x7fffffff,(%ebx,%ebp,1) |
83 /5 ib | subw imm8,r/m16 | 2/7 |
Subtract sign-extended immediate byte from r/m word | subw $0x7f,%cx
subw $0x7f,(%ebx,1)
subw $0x7f,(%ebx,2)
subw $0x7f,(%ebx,%ebp,1) |
83 /5 ib | subl imm8,r/m32 | 2/7 |
Subtract sign-extended immediate byte from r/m dword | subl $0x7f,%ecx
subl $0x7f,(%ebx,2)
subl $0x7f,(%ebx,4)
subl $0x7f,(%ebx,%ebp,1) |
28 /r | subb r8,r/m8 | 2/6 |
Subtract byte register from r/m byte | subb %bh,%dl
subb %bh,(%ebx,1)
subb %bh,m8(%ebx,1)
subb %bh,m8(%ebx,%ebp,1) |
29 /r | subw r16,r/m16 | 2/6 |
Subtract word register from r/m word | subw %bx,%cx
subw %bx,(%ebx,1)
subw %bx,(%ebx,2)
subw %bx,(%ebx,%ebp,1) |
29 /r | subl r32,r/m32 | 2/6 |
Subtract dword register from r/m dword | subl %ebx,%ecx
subl %ebx,(%ebx,2)
subl %ebx,(%ebx,4)
subl %ebx,(%ebx,%ebp,1) |
2A /r | subb r/m8,r8 | 2/7 |
Subtract byte register from r/m byte | subb %dl,%bh
subb (%ebx,1),%bh
subb m8(%ebx,1),%bh
subb m8(%ebx,%ebp,1),%bh |
2B /r | subw r/m16,r16 | 2/7 |
Subtract word register from r/m word | subw %cx,%bx
subw (%ebx,1),%bx
subw (%ebx,2),%bx
subw (%ebx,%ebp,1),%bx |
2B /r | subl r/m32,r32 | 2/7 |
Subtract dword register from r/m dword | subl %ecx,%ebx
subl (%ebx,2),%ebx
subl (%ebx,4),%ebx
subl (%ebx,%ebp,1),%ebx |
Operation
IF SRC is a byte and DEST is a word or dword
THEN DEST := DEST - SignExtend(SRC);
ELSE DEST := DEST - SRC;
FI;
Description
SUB subtracts the second operand (SRC) from the first operand (DEST). The first operand is assigned the result of the subtraction, and the flags are set accordingly.
When an immediate byte value is subtracted from a word operand, the immediate value is first sign-extended to the size of the destination operand.
Flags Affected
OF, SF, ZF, AF, PF, and CF as described in Appendix C
Protected Mode Exceptions
#GP(0) if the result is in a nonwritable segment; #GP(0) for an illegal memory operand effective address in the CS, DS, ES, FS, or GS segments; #SS(0) for an illegal address in the SS segment; #PF(fault-code) for a page fault
Real Address Mode Exceptions
Interrupt 13 if any part of the operand would lie outside of the effective address space from 0 to 0FFFFH
Virtual 8086 Mode Exceptions
Same exceptions as in Real Address Mode; #PF(fault-code) for a page fault
[Home Page dell'ITIS "Fermi"]
[80386 Programmer's Reference Manual Index]
[Previous]
[Next]
|