Bismillahir Rahmanir Rahim
At first we have to know about some DOS function .
Few of the functions of DOS interrupt 21h are described bellow :
a. Function 01h : Keyboard input Output: returns the ASCII code of key pressed in AL MOV AH, 01h
INT 21h
b. Function 02h : Display a character, whose ASCII code is in DL
MOV AH, 02h
MOV DL, character (character means variable name)
INT 21h .
c. Function 09h : Print string, DS:DX contains pointer to the character string ending with ‘$’ or 24h (end of string marker)
MOV AH, 09h
MOV DX, OFFSET character
INT 21h
d. Function 4Ch : Terminate current process MOV AH, 4Ch and transfer controls to the invoking MOV AL, 00h process. AL contains the return code INT 21h
Solution:
datas SEGMENT aa DB 00h bb DB 00h cc db 00h first db "Enter your first number or Alphabat- $" secand db "Enter your secand number or Alphabat- $" datas ENDS staks SEGMENT DB 100 dup() staks ENDS codes SEGMENT ASSUME CS: codes, DS: datas, SS: staks Start: MOV AX, SEG datas MOV DS, AX MOV CX, SEG staks MOV SS, CX mov dx,offset first mov ah,09 int 21h MOV AH, 01h ; function - input from keyboard INT 21h ; DOS call ; ASCII of key pressed is in AL SUB al, 30h ; convert into binary MOV aa, al mov dx,offset secand mov ah,09 int 21h MOV AH, 01h INT 21h SUB al, 30h MOV bb, al MOV AL, aa MOV BL, bb CMP AL, BL ;AL > BL ? JBE ELSE_L ; No THEN: ; Yes SUB AL, BL MOV cc, AL JMP DISP_L ELSE_L: SUB BL, AL MOV cc, BL DISP_L: MOV DL, cc ADD DL, 30h ; convert binary into ASCII MOV AH, 02h ; call display character function INT 21h ; OS call to display it MOV AX, 4C00h INT 21h codes ENDS END START