An assembly program that converts 2 ASCII digits stored in two registers (say BH and BL) into an equivalent binary number – IGNOU BCA Assignment 2016 – 17

By | October 9, 2016

BACHELOR OF COMPUTER APPLICATIONS

Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(2)/L-022/Assignment/16-17
Maximum Marks : 50
Weightage : 25%

 

Write and run (using appropriate calling program) a near procedure in 8086 assembly language that converts 2 ASCII digits stored in two registers (say BH and BL) into an equivalent binary number. For example, if the BH and BL registers contain digits 4 and 5 respectively, then the binary number obtained will be 0010 1101 which is 45 in decimal. The parameters should be passed using registers and the result should be returned in AL register – IGNOU MCA Assignment 2016 – 17

Code:-

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

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

 

Screen Shots :-

Asm_program_Ascii _2digit_To_Binary_v3

Output Before Execution :-

Asm_program_Ascii _2digit_To_Binary_v4

Output After Execution :-

Asm_program_Ascii _2digit_To_Binary_v5.1

Asm_program_Ascii _2digit_To_Binary_v5

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