Answer to Question #149819 in Assembler for vastav

Question #149819
Write and run (using appropriate calling program) a near procedure in 8086 assembly
language, which is passed a single parameter by the calling program. The procedure
checks if the input parameter has a value zero or not. If the value of input parameter is
zero then procedure/program is terminated, otherwise a value of 1 is returned to the
calling program, which then continue to execute the remaining program. Make and state
suitable assumptions, if any.
1
Expert's answer
2020-12-09T08:14:19-0500

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


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS