Logo 
Search:

Assembly Language Articles

Submit Article
Home » Articles » Assembly Language » Homework HelpRSS Feeds

Program to convert decimal number to binary

Posted By: Adelita Fischer     Category: Assembly Language     Views: 18855

Write a program to convert decimal number to binary.

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

;------
;OUTPUT
;------

    BINARY NUMBER IS : 1100100
  
Share: 


Didn't find what you were looking for? Find more on Program to convert decimal number to binary Or get search suggestion and latest updates.

Adelita Fischer
Adelita Fischer author of Program to convert decimal number to binary is from Frankfurt, Germany.
 
View All Articles

 

Other Interesting Articles in Assembly Language:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!