140 likes | 291 Views
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.
E N D
Lab 3 LEA Instruction, JMP, CMP, Conditional Jump, Loop
LEA Instruction • LEA
Unconditional Jumps – JMP Instruction • JMP destination_lable • LABEL1:
CMP Instruction CMP 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 – AND condition • Read a character, and if it’s an uppercase letter, Accept it
Example – OR Condition • Read a character. If it’s 'y' or 'Y', display it; otherwise, terminate the program.
LOOP Instruction LOOP destination_Label Display a row of 80 stars
Example – While Loop • Count number of characters entered and terminate if carriage return is entered.
Example – Repeat Loop • Read characters until a blank is read terminate.
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$"