MP Instructions
MP Instructions
MP Instructions
Instruction Set:
Unconditional Jump.
JMP Label Transfers control to another part of the program. 4-byte address
may be entered in this form: 1234h: 5678h, first value is a
segment second value is an offset.
JA Label Short Jump if first operand is Above second operand (as set by
CMP instruction). Unsigned.
if CF = 0 then jump
Jump If Below.
JB Label Short Jump if first operand is Below second operand (as set by
0LFURSURFHVVRU/DE
Algorithm:
if CF = 1 then jump
Jump If Below Or Equal
JBE Label Short Jump if first operand is Below second operand (as set by
CMP instruction). Unsigned.
Algorithm:
if CF = 1 then jump
Jump If Carry
Algorithm:
if CF = 1 then jump
Jump If Equal.
JE Label Short Jump if first operand is Equal to second operand (as set
by CMP instruction). Signed/Unsigned.
Algorithm:
if ZF = 1 then jump
Jump If Greater
JG Label Short Jump if first operand is Greater then second operand (as
set by CMP instruction). Signed.
Algorithm:
Algorithm:
if SF = OF then jump
Jump If Less than.
JL Label Short Jump if first operand is Less then second operand (as set
by CMP instruction). Signed.
Algorithm:
JLE Label Short Jump if first operand is Less or Equal to second operand
(as set by CMP instruction). Signed.
Algorithm:
0LFURSURFHVVRU/DE
JNZ Label Short Jump if Not Zero (not equal). Set by CMP, SUB, ADD,
TEST, AND, OR, XOR instructions.
Algorithm:
if ZF = 0 then jump
Jump If Zero.
JZ Label Short Jump if Zero (equal). Set by CMP, SUB, ADD, TEST,
AND, OR, XOR instructions.
Algorithm:
if ZF = 1 then jump
Load Effective Address.
Algorithm:
LOOP Label
• CX = CX - 1
• if CX <> 0 then
o jump
else
o no jump, continue
Add.
REG, memory
ADD memory, REG Algorithm:
REG, REG
memory, immediate operand1 = operand1 + operand2
REG, immediate
Subtract.
REG, memory
memory, REG Algorithm:
SUB REG, REG
memory, immediate operand1 = operand1 - operand2
REG, immediate
• CF = 1
Decimal adjust After Subtraction.
Corrects the result of subtraction of two packed BCD values.
• CF = 1
Increment.
REG Algorithm:
DIV Memory
when operand is a byte:
AL = AX / operand
AH = remainder (modulus)
when operand is a word:
AX = (DX AX) / operand
DX = remainder (modulus)
0LFURSURFHVVRU/DE
Shift Left.
memory, immediate
SHL REG, immediate Shift operand1 Left. The number of shifts is set by operand2.
memory, CL Algorithm:
REG, CL
• Shift all bits left, the bit that goes off is set to CF.
• Zero bit is inserted to the right-most position.
Shift Right.
memory, immediate
SHR REG, immediate Shift operand1 Right. The number of shifts is set by operand2.
memory, CL Algorithm:
REG, CL
• Shift all bits right, the bit that goes off is set to CF.
• Zero bit is inserted to the left-most position.
Rotate Left.
memory, immediate
REG, immediate Rotate operand1 left. The number of rotates is set by operand2.
ROL
memory, CL Algorithm:
REG, CL
Shift all bits left, the bit that goes off is set to CF and
the same bit is inserted to the right-most position.
Rotate Right.
memory, immediate
REG, immediate Rotate operand1 right. The number of rotates is set by
ROR operand2.
memory, CL
REG, CL Algorithm:
Shift all bits right, the bit that goes off is set to CF and
the same bit is inserted to the left-most position.
procedure name Transfers control to procedure, return address is (IP) pushed to
CALL label stack.
REG Algorithm:
PUSH SREG
memory • SP = SP - 2
Algorithm:
AAA No Operands
else
• AF = 0
• CF = 0
in both cases:
cLear the high nibble of AL.
Example:
MOV AX, 15 ; AH = 00, AL = 0Fh
AAA ; AH = 01, AL = 05
ASCII Adjust after Subtraction.
Corrects result in AH and AL after subtraction when working
with BCD values.
0LFURSURFHVVRU/DE
Algorithm:
else
• AF = 0
• CF = 0
in both cases:
cLear the high nibble of AL.
Example:
MOV AX, 02FFh ; AH = 02, AL = 0FFh
AAS ; AH = 01, AL = 09
Algorithm:
• AH = AL / 10
AAM No Operands • AL = remainder
Example:
MOV AL, 15 ; AL = 0Fh
AAM ; AH = 01, AL = 05
0LFURSURFHVVRU/DE