Keyboard Processing With Control Flow: Julius Bancud
Keyboard Processing With Control Flow: Julius Bancud
Keyboard Processing With Control Flow: Julius Bancud
JE JUMP IF EQUAL
JNE JUMP IF NOT EQUAL
JL JUMP IF LESS THAN
JLE JUMP IF LESS THAN OR EQUAL TO
JG JUMP IF GREATER THAN
JGE JUMP IF GREATER THAN OR EQUAL TO
JZ JUMP IF ZERO
JNZ JUMP IF NOT ZERO
CONDITIONAL JUMP INSTRUCTIONS
Format:
<conditional jump instruction> <label>
Example:
CMP AL, ‘Y’
JE TAMA
CMP AL, ‘N’
JE MALI
TAMA: MOV AH, 09h
MOV DX, OFFSET ANS1
INT 21h
UNCONDITIONAL JMP
JMP is considered as unconditional jump instruction because it is always executed by the
machine. It does not depend on a condition being true or false.
Format:
JMP <label>
Example:
CMP AL, ‘Y’
JE TAMA
CMP AL, ‘N’
JE MALI
JMP TAPOS
TAMA: MOV AH, 09h
MOV DX, OFFSET ANS1
INT 21h
TAPOS: MOV AX, 4C00H
INT 21h
IF .. ELSE CONSTRUCT
A conditional statement of C language in the form:
if < condition>
{
<statement-1>;
<statement-2>;
<statement-n>;
}
else
{
<statement-1>;
<statement-2>;
<statement-n>;
}
IF .. ELSE CONSTRUCT
Can be implemented by assembly language of the form:
<CMP instruction>
<conditional jmp instruction> <label-1>
<instruction-1>
<instruction-1>
…
<instruction-n>
< jmp instruction> <label-2>
IF .. ELSE CONSTRUCT
C LANGUAGE ASSEMBLY LANGUAGE
If (ax == 0)
{
cx = cx – ax; CMP AX, 0000h
ax = ax + 1 JNZ ACTION1
} SUB CX, AX
INC AX
JMP NEXT
else
{ ACTION1: SUB CX, 0008h
cx = cx – 8;
} NEXT:
DO .. WHILE CONSTRUCT
while<condition>
{
<statement-1>
<statement-2>
….
<statement-n>
}
Is roughly equivalent to an assembly language structure:
<label-2> <instruciton-1>
<instruciton-2>
…
<instruciton-n>
Example
C Language Assembly Language
Example:
NEYM DB 08h, ?, 08h DUP(“$”)
08H 04H v a l e $ 0Dh
0 1 2 3 4 5 6 7
STRING INPUT