Chapter 4
Chapter 4
INSTRUCTIONS
Example
XCHG [5000H], AX ; This instruction exchanges data
between AX and a ; memory location [5000H] in the data
segment.
Example: Program
STC ; set CF = 1
MOV AL, 5 ; AL = 5
ADC AL, 1 ; AL = 7
RET
INC and DEC
INC: Increment
This instruction increments the contents of the specified register or
memory location by 1.
All the condition code flags are affected except the carry flag CF.
This instruction adds 1 to the contents of the operand.
Program
The examples of this instruction are as follows: Example:
INC AX Register MOV AL, 4
INC [BX] Register indirect INC AL ; AL = 5
INC [5000H] Direct
RET
Example:
DEC: Decrement
The decrement instruction subtracts 1 from the contents of the specified
register or memory location.
All the condition code flags except carry flag are affected depending upon
the result.
The examples of this instruction are as follows: Program Example:
DEC MOV AL, 255 ; AL = 0FFh (255 or -
AX Register
DEC [500OH]
1)
Direct
DEC AL ; AL = 0FEh (254 or -2)
RET
SUB: Subtract
The subtract instruction subtracts the source
operand from the destination operand and the
result is left in the destination operand.
Source operand may be a register, memory location
or immediate
data and the destination operand may be a register
or a memory location, but source and destination
operands both must not be memory operands.
All the condition code flags are affected by this
instruction.
examples
SUB AX, BX Register
SUB AX, [5000H] Direct
SUB [5000H], 0100 Immediate
SUB CL,BL CL = CL – BL
SBB: Subtract with Borrow
The subtract with borrow instruction subtracts the
source operand and the borrow flag (CF) which
may reflect the result of the previous calculations,
from the destination operand.
Subtraction with borrow, here means subtracting 1
from the subtraction obtained by SUB, if carry
(borrow) flag is set.
The result is stored in the destination operand. All
the flags are affected (Condition code) by this
instruction.
Example
SBB O100H Immediate [destination AX]
SBB AX.BX Register
SBB AX, [5000H] Direct
Example Program:
MUL , IMUL, DIV and IDIV
These types of operands are supported:
REG
Memory
REG:AX, BX, CX, DX, AH, AL, BL, BH, CH, CL, DH, DL, DI, SI, BP, SP.
memory: [BX], [BX+SI+7], variable, etc...