Tuesday, 28 July 2015

Write· a program to read one of the hex digits A-F, and Display it on the next line in decimal In Assembly Language Using Function/Procedure.

Write· a program to read one of the hex digits A-F, and Display it
on the next line in decimal.
Sample execution: ENTER A HEX DIGIT: C
IN DECIMAL IT IS 12
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/
TAG: EASY SOLUTION , 8086 MICROPROCESSOR, ASSEMBLY LANGUAGE CHAPTER 4 , PROGRAMMING EXERCISE ,
FUNCTION/PROCEDURE ,ASSEMBLY LANGUAGE PROGRAMMING AND ORGANIZATION OF THE IBM PC - CHAPTER 4.

Solution:

.MODEL SMALL
.STACK 100H
.DATA
    STR1 DB 'ENTER A HEX DIGIT: $'
    STR2 DB 0AH,0DH,'IN DECIMAL IT IS 1'
    ANS DB ?
    STR3 DB '$'
.CODE
MAIN PROC
    
    MOV AX,@DATA
    MOV DS,AX
    
    CALL INPUT_MSG_FUNC
    CALL INPUT_FUNC
    CALL CALCULATION_FUNC
    CALL OUTPUT_FUNC
    
    MOV AH,4CH
    INT 21H
    
    MAIN ENDP          

INPUT_MSG_FUNC PROC 
    
    MOV AH,9
    LEA DX,STR1
    INT 21H
    RET
    
    INPUT_MSG_FUNC ENDP

INPUT_FUNC PROC
    
    MOV AH,1
    INT 21H
    RET
    
    INPUT_FUNC ENDP 

CALCULATION_FUNC PROC
    
    SUB AL,11H
    MOV ANS,AL
    RET
    
    CALCULATION_FUNC ENDP

OUTPUT_FUNC PROC
    
    MOV AH,9
    LEA DX,STR2
    INT 21H
    RET
    
    OUTPUT_FUNC ENDP 

END MAIN

No comments:

Post a Comment