MASTER OF COMPUTER APPLICATIONS
Course Code : MCSL-017
Course Title : C and Assembly Language Programming (Lab Course)
Assignment Number : MCA(1)/L-017/Assignment/17-18
Maximum Marks : 50
Weightage : 25%
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 – IGNOU MCA Assignment 2017 – 18
Code:-
DATA SEGMENT
ARR DB ‘3’,’4′,’5′
HUN DB ?
TEN DB ?
UNT DB ?
LEN DW $-ARR
RES DW ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARR
MOV AL,ARR[SI]
SUB AL,30H
MOV HUN,AL
INC SI
MOV AL,ARR[SI]
SUB AL,30H
MOV TEN,AL
INC SI
MOV AL,ARR[SI]
SUB AL,30H
MOV UNT,AL
MOV AX,0
MOV CL,100
MOV AL,HUN
MUL CL
MOV BX,AX
MOV AX,0
MOV CL,10
MOV AL,TEN
MUL CL
ADD AX,BX
MOV BX,0
MOV BL,UNT
ADD AX,BX
MOV RES,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
[codesyntax lang=”asm”]
DATA SEGMENT
ARR DB ‘3’,’4′,’5′
HUN DB ?
TEN DB ?
UNT DB ?
LEN DW $-ARR
RES DW ?
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,ARR
MOV AL,ARR[SI]
SUB AL,30H
MOV HUN,AL
INC SI
MOV AL,ARR[SI]
SUB AL,30H
MOV TEN,AL
INC SI
MOV AL,ARR[SI]
SUB AL,30H
MOV UNT,AL
MOV AX,0
MOV CL,100
MOV AL,HUN
MUL CL
MOV BX,AX
MOV AX,0
MOV CL,10
MOV AL,TEN
MUL CL
ADD AX,BX
MOV BX,0
MOV BL,UNT
ADD AX,BX
MOV RES,AX
MOV AH,4CH
INT 21H
CODE ENDS
END START
[/codesyntax]
Screen Shots :-
Before Execution :-
After Execution :-
Note :- To see the variable and its value you have to click vars button in the emulator.