Program: This program compares a pair of characters entered by keyboard.
; Registers used: AX, BX, CX, DX
DATA SEGMENT
XX DB?
YY DB?
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
MAINP: MOV AX, DATA; initialize data
MOV DS, AX; segment using AX
MOV CX, 03H; set counter to 3.
NEXTP: MOV AH, 01H; Waiting for user to enter a char.
INT 21H
MOV XX, AL; store the 1st input character in XX
MOV AH, 01H; waiting for user to enter second
INT 21H ; character.
MOV YY, AL; store the character to YY
MOV BH, XX; load first character in BH
MOV BL, YY; load second character in BL
CMP BH, BL; compare the characters
JNE NOT_EQUAL;
EQUAL: MOV AH, 02H; if characters are equal then control
MOV DL, 'Y' ; will execute this block and
INT 21H ; display 'Y'
JMP CONTINUE; Jump to continue loop.
NOT_EQUAL: MOV AH, 02H; if characters are not equal then
Control
MOV DL, 'N'' ; will execute this block and
INT 21 H ; display 'N'
CONTINUE: LOOP NEXT P ; Get the next character
MOV AH, 4C H; Exit to DOS
INT 21 H
CODE ENDS
END MAINP