VOOZH about

URL: https://www.geeksforgeeks.org/computer-organization-architecture/8086-program-to-convert-a-16-bit-decimal-number-to-binary/

⇱ 8086 program to convert a 16 bit decimal number to binary - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

8086 program to convert a 16 bit decimal number to binary

Last Updated : 21 Aug, 2025

Problem: We are given a 16 bit decimal number we have to print the number in binary format

Examples:

Input: d1 = 16
Output: 10000

Input: d1 = 7
Output: 111

Explanation:

  1. Load the value stored into register
  2. Divide the value by 2 to convert it to binary
  3. Push the remainder into the stack
  4. Increase the count
  5. Repeat the steps until the value of the register is greater than 0
  6. Until the count is greater than zero
  7. POP the stack
  8. Add 48 to the top element to convert it into ASCII
  9. Print the character using interrupt
  10. Decrements the count

Program:

Output:

10000

Note: The program cannot be run on an online editor, please use MASM to run the program and use dos box to run MASM, you might use any 8086 emulator to run the program

Comment

Explore