Chapter 6
Chapter 6
Chapter 6
JMP INSTRUCTION
Purpose: Unconditional jump.
Syntax:
JMP destiny
This instruction is used to deviate the flow of a program without
taking into account (connsideration) the actual conditions of the
flags or of the data.
JA (JNBE) INSTRUCTION
Purpose: Conditional jump.
Syntax:
JA Label
After a comparison this command jumps if it is or jumps if it is not
down or if not it is the equal.
This means that the jump is only done if the CF flag is deactivated or if
the ZF flag is deactivated, that is that one of the two be equal to zero.
JAE (JNB) INSTRUCTION
Purpose: Conditional jump.
Syntax:
JAE label
It jumps if it is or it is the equal or if it is not down.
The jump is done if CF is deactivated.
1. JB (JNAE) INSTRUCTION
Purpose: Conditional jump.
Syntax:
JB label
It jumps if it is down, if it is not , or if it is the equal.
The jump is done if CF is activated.
1. JE (JZ) INSTRUCTION
Purpose: Conditional jump.
Syntax:
JE label
It jumps if it is the equal or if it is zero.
The jump is done if ZF is activated.
1. JNE (JNZ) INSTRUCTION
Purpose: Conditional jump.
Syntax:
JNE label
It jumps if it is not equal or zero.
The jump will be done if ZF is deactivated.
Instructions for cycles: loop
They transfer the process flow, conditionally or unconditionally, to a destiny, repeating this action until the counter
is zero.
LOOP
LOOPE
LOOPNE
LOOP INSTRUCTION
Purpose: To generate a cycle in the program.
Syntax:
LOOP label
The loop instruction decreases CX on 1, and transfers the flow of the program to the label given as operator if CX
is different than 1.
LOOPE INSTRUCTION
Purpose: To generate a cycle in the program considering the state of ZF.
Syntax:
LOOPE label
This instruction decreases CX by 1. If CX is different to zero and ZF is equal to 1, then the flow of the program is
transferred to the label indicated as operand.
LOOPNE INSTRUCTION
Purpose: To generate a cycle in the program, considering the state of ZF.
Syntax:
LOOPNE label
This instruction decreases one from CX and transfers the flow of the program only if ZF is different to 0.
1.Counting instructions
They are used to decrease or increase the content of the counters.
DEC
INC
DEC INSTRUCTION
Purpose: To decrease the operator
Syntax:
DEC destiny
This operation subtracts 1 from the destiny operator and stores the
new value in the same operator.
INC INSTRUCTION
Purpose: To increase the operator.
Syntax:
INC destiny the instruction adds 1 to the destiny operator and keeps
the result in the same destiny operator.
Comparison instructions
CMP INSTRUCTION
Purpose: To compare the operators.
Syntax:
CMP destiny, source
This instruction subtracts the source operator from the
destiny operator but without this one storing the result of the
operation, and it only affects the state of the flags.
Flag instructions
Purpose: Conditional jump, and the state of the flags is taken into account.
Syntax:
JO label
It jumps if there is overflow.
The jump is done if OF = 1.
JP (JPE) INSTRUCTION
Purpose: Conditional jump, the state of the flags is taken into account.
Syntax:
JP label
It jumps if there is parity or if the parity is even.
The jump is done if PF = 1.
JS INSTRUCTION
Purpose: Conditional jump, and the state of the flags is taken into account.
Syntax:
JS label
It jumps if the sign is on.
The jump is done if SF = 1.
MOV AX.MyData ; Set up our own data segment address
in DS
MOV DS,AX ; Can't load segment reg. directly from
memory
MyData, if you recall, contains the segment address of a segment
defined using the
SEGMENT and ENDS directives. That address is first loaded into
AX, and then from
AX the address is loaded into DS. This roundabout path is
necessary because the DS
register cannot be loaded with either immediate data or memory data; it
must be loaded
from one of the other registers.
Never forget that the assembler follows
its orders without
understanding them. It doesn't make inferences based on what you do to addresses or the
segment registers. It must be told which segment is to be used as the data segment, the
code segment, and the stack segment. Somewhere inside the assembler program is a little
table where the assembler "remembers" that segment MyData is to be considered the data
segment, and that segment MyCode is to be considered the code segment, and that
segment MyStack is to be considered the stack segment. It can't remember these
relationships, however, unless you first tell the assembler what they are somehow.
This somehow (for the data, code, and extra segments, at least) is the ASSUME
directive. The ASSUME directive in EAT.ASM tidily specifies that MyData is the data
segment and MyCode is the code segment.
Why is this important? It has to do with the way the assembler creates the binary opcodes
for a given instruction. When you write an instruction that addresses memory data like
this