8086 Assembly Program to Convert BCD Number into Binary Format

DATA SEGMENT
NO1 DB "9036"
D2 DB ?
D1 DB 16 DUP(?)
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE, DS:DATA
START:
MOV AX, DATA
MOV DS, AX
LEA SI, NO1
LEA DI, D1
MOV CX, 04H
TOP:
MOV AL, [SI]
MOV DX, 0CH
UP1:
ROL AX,1
DEC DX
JNZ UP1
AND AX, 1111000000000000B
MOV DX, 04H
UP2:
ROL AX, 1
JNC DN
MOV BX, 1
MOV [DI], BX
JMP DN2
DN:
MOV BX, 0
MOV [DI], BX
DN2:
INC DI
DEC DX
JNZ UP2
INC SI
DEC CX
JNZ TOP
INT 3
CODE ENDS
END START

Output

C:\TASM>MASM BCDBIN.ASM
Microsoft (R) Macro Assembler Version 5.00
Copyright (C) Microsoft Corp 1981-1985, 1987. All rights reserved.
Object filename [BCDBIN.OBJ]:
Source listing [NUL.LST]:
Cross-reference [NUL.CRF]:
50324 + 450332 Bytes symbol space free
0 Warning Errors
0 Severe Errors
C:\TASM>LINK BCDBIN.OBJ
Microsoft (R) Overlay Linker Version 3.60
Copyright (C) Microsoft Corp 1983-1987. All rights reserved.
Run File [BCDBIN.EXE]:
List File [NUL.MAP]:
Libraries [.LIB]:
LINK : warning L4021: no stack segment
C:\TASM>DEBUG BCDBIN.EXE
-G
AX=0006 BX=0000 CX=0000 DX=0000 SP=0000 BP=0000 SI=0004 DI=0015
DS=0B97 ES=0B87 SS=0B97 CS=0B99 IP=0039 NV UP EI PL ZR NA PE NC
0B99:0039 CC INT 3
-D 0B97:0000
0B97:0000 39 30 33 36 00 01 00 00-01 00 00 00 00 00 00 01 9036............
0B97:0010 01 00 01 01 00 00 00 00-00 00 00 00 00 00 00 00 ................
0B97:0020 B8 97 0B 8E D8 8D 36 00-00 8D 3E 05 00 B9 04 00 ......6...>.....
0B97:0030 8A 04 BA 0C 00 D1 C0 4A-75 FB 25 00 F0 BA 04 00 .......Ju.%.....
0B97:0040 D1 C0 73 08 BB 01 00 89-1D EB 06 90 BB 00 00 89 ..s.............
0B97:0050 1D 47 4A 75 EB 46 49 75-D7 CC 26 80 7F 0A 00 74 .GJu.FIu..&....t
0B97:0060 3E 8B 46 08 8B 56 0A 89-46 FC 89 56 FE C4 5E FC >.F..V..F..V..^.
0B97:0070 26 8A 47 0C 2A E4 40 50-8B C3 05 0C 00 52 50 E8 &.G.*[email protected]
-Q

One thought on “8086 Assembly Program to Convert BCD Number into Binary Format”

  1. hi Ankur,

    thanks for your efforts to give so many assembly programs.
    can i request you to please add output printing code to each too.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.