Upload
amena-salinas
View
31
Download
0
Tags:
Embed Size (px)
DESCRIPTION
Lab 3. LEA Instruction, JMP, CMP, Conditional Jump, Loop. LEA Instruction. LEA. Unconditional Jumps – JMP Instruction. JMP destination_lable LABEL1:. Conditional Jumps – Signed Jumps. Conditional Jumps – Unsigned Jumps. Conditional Jumps – Single Flag Jumps. CMP Instruction. - PowerPoint PPT Presentation
Citation preview
Conditional Jumps – Signed Jumps
Symbol Description Condition JG / JNLE jump if grater than
jump if not less than or equalZF = 0 & SF = OF
JGE / JNL jump if grater than or equaljump if not less than
SF = OF
JL / JNGE jump if less thanjump if not greater than or equal
SF <> OF
JLE / JNG jump if less than or equaljump if not grater than
ZF = 1 or SF <> OF
Conditional Jumps – Unsigned Jumps
Symbol Description Condition
JA / JNBE jump if abovejump if not below or equal
CF = 0 & ZF = 0
JAE / JNB jump if above or equaljump if not below
CF = 0
JLB/ JNAE jump if belowjump if not above or equal
CF = 1
JBE / JNA jump if below or equaljump if not above
CF = 1 or ZF = 1
Conditional Jumps – Single Flag Jumps
Symbol Description ConditionJE / JZ jump if equal/ jump if equal to 0 ZF = 1JNE / JNZ jump if not equal/ jump if not 0 ZF = 0 JC jump if carry CF = 1JNC jump if no carry CF = 0JO jump if overflow OF = 1JNO jump if no overflow OF = 0JS jump if sign negative SF = 1 JNS jump if nonnegative sign SF = 0JP / JPE jump if parity even PF = 1JNP / JPO jump if parity odd PF = 0
CMP InstructionCMP destination, source
Just like SUB but the destination does not change.
Changes the Flags
Used with conditional jumps
Example – IF, THEN, ELSE•Suppose AL and BL contain extended ASCII characters, Display the one that comes first in the character sequence
Example – OR Condition•Read a character. If it’s 'y' or 'Y', display it; otherwise, terminate the program.
Example – While Loop Count number of characters entered and terminate if carriage return is entered.
Exercises Read characters from user and count the number of characters if they reached 30 display a message “The Program Cannot Accept anymore characters.”
org 100h MOV AH,1 ;PREPARE function TO read MOV CL,0 ;clear the register to count GO_TOP: INT 21H ;execute function INC CL ;increment to count the number of characters entered CMP CL,30 ;compare if CL equals 30 to break out the loop JE DISPLAY_MSG ;jumping to display to show JMP GO_TOP DISPLAY_MSG: MOV AH,9 LEA DX,MESG INT 21H ret MESG DB 0DH,0AH,"The Program Cannot Accept anymore characters$"