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 Assembly Language Solution.


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.
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
 
    MOV AH,9
    LEA DX,STR1
    INT 21H
 
    MOV AH,1
    INT 21H
 
    SUB AL,11H
    MOV ANS,AL
 
    MOV AH,9
    LEA DX,STR2
    INT 21H
 
    MOV AH,4CH
    INT 21H
    MAIN ENDP
END MAIN

No comments:

Post a Comment