Professional Documents
Culture Documents
• The knowledge will help you write lines of code or program by which you will be
able to tell the processor, the sequence of operations to be performed.
Types of instructions
• Arithmetic instructions
• Logical instructions
• String instructions
Eg:
PUSH Source
Pushes the 16 bit content specified by source in the instruction on to the
stack
Eg: PUSH BX
POP Destination
• Pops the 16 bit content from stack to destination specified in instruction.
Eg: POP DS
AH AL 50 12
00 BX
Arithmetic Instructions
Addition
Subtraction
Increment
Decrement
Multiply
Divide
Compare
Arithmetic Instructions
ADD Destination, Source
This instruction adds the contents of source operand with the contents of destination operand. The result is
stored in destination operand.
Eg:
The source may be immediate data,
memory location or register. • ADD AX,BX
The destination may be memory location • ADD AX,[0300H]
or register.
AX is the default destination register. • ADD [0200H],BX
• ADD AX,05H
• ADD [0300H],05H
Arithmetic Instructions
ADC Destination, Source
This instruction adds the contents of source operand with the contents of destination operand with carry flag
bit.
INC source
This instruction increases the contents of source operand by 1.
Eg: INC AX
The source may be memory location or
register.
The source can not be immediate data. AX AX
The result is stored in the same place.
70 01
00 70 00 + 1
AH AL AH AL
Arithmetic Instructions
SUB Destination, Source
This instruction subtracts the contents of source operand with the contents of destination operand. The result
is stored in destination operand.
Eg:
The source may be immediate data,
memory location or register. • SUB AX,BX
The destination may be memory location • SUB AX,[0300H]
or register.
AX is the default destination register. • SUB [0200H],BX
• SUB AX,05H
• SUB [0300H],05H
Arithmetic Instructions
SBB Destination, Source
This instruction subtracts the contents of source operand with the contents of destination operand with carry
flag bit.
DEC source
This instruction decreases the contents of source operand by 1.
Eg: DEC AX
The source may be memory location or
register.
The source can not be immediate data. AX AX
The result is stored in the same place.
00 04
00 00 05 - 1
AH AL AH AL
Arithmetic Instructions
MUL operand
This instruction will multiple unsigned operand 8-bit/16-bit with AL/AX and store the result in AX/DX-AX.
Eg: MUL BH
Operand may be general purpose register IMUL BH
or memory location.
If operand is of 8-bit then multiply it with AX AX BX
contents of AL.
If operand is of 16-bit then multiply it XX XX
00 08 XX 04 X 12
02 XX
with contents of AX.
AH AL AH AL BH BL
Result is stored in accumulator AX in 8
bit operation and DX-AX in 16bit
operation.
Arithmetic Instructions
DIV Operand
This instruction will divide unsigned operand AX/DX-AX by 8-bit/16-bit number and store the result in
AX/DX-AX
Eg: DIV BL
Operand may be general purpose register IDIV BL
or memory location.
AL=AX/Operand (8-bit)
AX AX BX
AL= Quotient, AH=Remainder.
AX=DX-AX/Operand (16-bit)
88
04 88
04 88 88 / XX 12
22
AX= Quotient, DX=Remainder. AH AL AH AL BH BL
Arithmetic Instructions
CMP REG1, REG2
This instruction compares the content of registers.
The result change the status of flag.
Eg: CMP AX,BX
The reg1 may be immediate data, memory
location or register.
CF AX BX
The reg2 may be immediate data, memory
location or register.
It afftects the carry flag 01 50 00 - 12
80 00
AH AL BH BL
Arithmetic Instructions
CMP REG1, REG2
This instruction compares the content of registers.
The result change the status of flag.
Eg: CMP AX,BX
The reg1 may be immediate data, memory
location or register. CMP AX,BX
The reg2 may be immediate data, memory CMP AX,[0300H]
location or register.
CMP [0200H],BX
It afftects the carry flag
CMP AX,05H
CMP [0300H],05H
Logical Instructions
• AND
• OR
• XOR
• SHR
• SHL
• RCR
• RCL
Logical Instructions
AND
• Especially used in clearing certain bits (masking)
AX BX
Eg: AND BL, 0FH 88
XX 08 XX 88 X XX 12
0F
AH AL BH BL
• AND AX,05H
• AND [0300H],05H
Logical Instructions
OR
• Used to multiply each bit in a byte/word with the corresponding bit in another byte/word.
AX AX
Eg: MOV AX, 2000h 00
20 08 20 00 or 00 12
08
OR AX, 0008h AH AL AH AL
• OR AX,05H
• OR [0300H],05H
0010 0000 OR 0000 1000 = 0010 1000
This sets bit 4 in the AX register
Logical Instructions
XOR
• Used to multiply each bit in a byte/word with the corresponding bit in another byte/word.
AX AX
Eg: MOV AX, 2000h 00
20 08 20 00 XOR
00 12
08
XOR AX, 0008h AH AL AH AL
• XOR AX,05H
• XOR [0300H],05H
0010 0000 XOR 0000 1000 = 0010 1000
This sets bit 4 in the AX register
Logical Instructions
SHL
• The SHL (shift left) instruction performs a logical left shift on the destination operand,
filling the lowest bit with 0.
0
CF
After Before
CALL − Used to call a procedure and save their return address to the stack.
Eg: CALL Label
JMP − Used to jump to the provided address to proceed to the next instruction.
JMP Label
Branch instructions
Instructions to transfer the instruction during an execution with some conditions
Summery