An Assembly language program that converts an ASCII string containing decimal digits into equivalent binary number – IGNOU MCA Assignment 2017 – 18

By | December 10, 2017

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
MSG1 DB 10,13,’ENTER ANY STRING :- $’
MSG2 DB 10,13,’ENTERED STRING IS : $’
MSG3 DB 10,13,’ENTERED DATA IS NOT ALPABETS ! $’
MSG4 DB 10,13,’ENTERED DATA NOT A 4 DIGIT VALUE ! $’
MSG5 DB 10,13,’UPPER CASE OF STRING IS :- $’

FLAG DB 0H

P1 LABEL BYTE
M1 DB 0FFH
L1 DB ?
P11 DB 0FFH DUP (‘$’)
DATA ENDS

DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM

CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX

DISPLAY MSG1

LEA DX,P1
MOV AH,0AH
INT 21H

DISPLAY MSG2
DISPLAY P11

CHECK1: CMP L1,04H
JNE NOT4D

LEA SI,P11
MOV CH,0
MOV CL,L1
DEC CL

CHECK2:
CMP [SI],41H
JB INCFLAG
CMP [SI],7BH
JB NOINC
INCFLAG:
INC FLAG
NOINC:

INC SI
LOOP CHECK2

CHECK3: CMP FLAG,0H
JNE NOTALP

CONV:
LEA SI,P11

MOV CL,L1
MOV CH,0
CHECK4:
CMP [SI],61H
JB DONE1

CMP [SI],5BH

UPR: SUB [SI],20H

DONE1: INC SI
LOOP CHECK4

DISPLAY MSG5
DISPLAY P11

JMP DONE
NOTALP:
DISPLAY MSG3
JMP DONE

NOT4D:
DISPLAY MSG4

DONE:

MOV AH,4CH
INT 21H
CODE ENDS

END START

DATA SEGMENT
MSG1 DB 10,13,'ENTER ANY STRING :- $'
MSG2 DB 10,13,'ENTERED STRING IS : $'
MSG3 DB 10,13,'ENTERED DATA IS NOT ALPABETS ! $'
MSG4 DB 10,13,'ENTERED DATA NOT A 4 DIGIT VALUE ! $'
MSG5 DB 10,13,'UPPER CASE OF STRING IS :- $'
FLAG DB 0H
P1 LABEL BYTE
M1 DB 0FFH
L1 DB ?
P11 DB 0FFH DUP ('$')
DATA ENDS
DISPLAY MACRO MSG
MOV AH,9
LEA DX,MSG
INT 21H
ENDM
CODE SEGMENT
ASSUME CS:CODE,DS:DATA
START:
MOV AX,DATA
MOV DS,AX
DISPLAY MSG1
LEA DX,P1
MOV AH,0AH
INT 21H
DISPLAY MSG2
DISPLAY P11
CHECK1: CMP L1,04H
JNE NOT4D
LEA SI,P11
MOV CH,0
MOV CL,L1
DEC CL
CHECK2:
CMP [SI],41H
JB INCFLAG
CMP [SI],7BH
JB NOINC
INCFLAG:
INC FLAG
NOINC:
INC SI
LOOP CHECK2
CHECK3: CMP FLAG,0H
JNE NOTALP
CONV:
LEA SI,P11
MOV CL,L1
MOV CH,0
CHECK4:
CMP [SI],61H
JB DONE1
CMP [SI],5BH
UPR: SUB [SI],20H
DONE1: INC SI
LOOP CHECK4
DISPLAY MSG5
DISPLAY P11
JMP DONE
NOTALP:
DISPLAY MSG3
JMP DONE
NOT4D:
DISPLAY MSG4
DONE:
MOV AH,4CH
INT 21H
CODE ENDS
END START

Screen Shots :-

Asm_program_4digit_2_UpperCase

After Execution :-

Asm_program_4digit_2_UpperCase_Output

Note :- To see the variable and its value you have to click vars button in the emulator.