-
Notifications
You must be signed in to change notification settings - Fork 15
/
decimal_to_binary.asm
52 lines (48 loc) · 924 Bytes
/
decimal_to_binary.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
;Code for Program to convert decimal number to binary in Assembly Language
DIS MACRO STR
MOV AH,09H
LEA DX,STR
INT 21H
ENDM
DATA SEGMENT
MSG2 DB "BINARY NUMBER IS : $"
STR1 DB 20 DUP('$')
STR2 DB 20 DUP('$')
NO DW 100
LINE DB 10,13,'$'
DATA ENDS
CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX
LEA SI,STR1
MOV AX,NO
MOV BH,00
MOV BL,2
L1:DIV BL
ADD AH,'0'
MOV BYTE PTR[SI],AH
MOV AH,00
INC SI
INC BH
CMP AL,00
JNE L1
MOV CL,BH
LEA SI,STR1
LEA DI,STR2
MOV CH,00
ADD SI,CX
DEC SI
L2:MOV AH,BYTE PTR[SI]
MOV BYTE PTR[DI],AH
DEC SI
INC DI
LOOP L2
DIS LINE
DIS MSG2
DIS STR2
MOV AH,4CH
INT 21H
CODE ENDS
END START