DATA SEGMENT
MSG_ENTER DB 10,13,"Enter input parameter (value zero or not): $"
MSG_NO DB 10,13,"The input parameter is not zero$"
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA DX,MSG_ENTER ; "Enter input parameter..."
MOV AH,9 ; Display string
INT 21H
MOV AH,1 ; Waiting for a key press
INT 21H
; AL = ASCII code of key pressed
; AL is input parameter
CALL My_PROC
CMP AL,0 ; Compare <returned value> with ZERO
JZ EXIT_PROG ; If<returned value> == 0 goto EXIT_PROG
LEA DX,MSG_NO ; Else display msg: "The input parameter is not zero"
MOV AH,9 ; Display string
INT 21H
EXIT_PROG: ; Program is terminated
MOV AH,4CH
INT 21H
;************************************************
; PROC My_PROC
; Input: AL=ASCII code of key
; Output: AL 0 or 1
;************************************************
My_PROC PROC NEAR
CMP AL,30H ; Compare AL with '0'
; 30h - ASCII code of '0'
JE RETURN_ZERO ; IF(AL==30h) -> RETURN AL=0
MOV AL,1 ; ELSE RETURN AL=1
JMP END_PROC
RETURN_ZERO:
MOV AL,0
END_PROC:
RET
My_PROC ENDP
CODE ENDS
END START
Comments
Leave a comment