Write and run an Assembly language program that converts an ASCII string containing decimal digits, stored in three consecutive locations in the memory into equivalent binary number. You may assume that the three locations contains ASCII equivalent of digit 3, digit 4 and digit 5. The output of this program should be stored in AX register.
Q:- Write and run an Assembly language program that converts an ASCII string containing decimal digits, stored in three consecutive locations in the memory into an equivalent binary number. You may assume that the three locations contains ASCII equivalent of digit 3, digit 4 and digit 5. The output of this program should be stored in AX register?
answer:-
DATA SEGMENT
MSG1 DB 10,13,’VALUE IN (BH REG.) IS : $’
MSG2 DB 10,13,’VALUE IN (BL REG.) IS : $’
BIN DB ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
MOV BH,4
MOV BL,5
LEA DX,MSG1
MOV AH,9H
INT 21H
MOV DL,BH
ADD DL,30H
MOV AH,2
INT 21H
LEA DX,MSG2
MOV AH,9H
INT 21H
MOV DL,BL
ADD DL,30H
MOV AH,2
INT 21H
CALL ASC2BIN
MOV AH,4CH
INT 21H
CODE ENDS
ASC2BIN PROC NEAR
MOV AL,BH
MOV CL,10
MUL CL
ADD AL,BL
MOV BIN,AL
RET
ASC2BIN ENDP
END START
Comments
Post a Comment