A number base converter

The problem

Write a program that reads a decimal number and prints it in binary and in hexadecimal, using the shift, mask and division instructions of the 8086.

Requirements

Technologies

Step by step

  1. Read the number into AX with the multiply-by-10 method, and keep it in BX.
  2. Print the 16 bits with SHL BX, 1 and ADC DL, 0, in a loop of 16.
  3. Write a procedure that turns a value from 0 to 15 into the characters 0 to 9 and A to F and prints it.
  4. Print the four hex digits by rotating BX left by 4 bits each time and masking the low 4 bits.
  5. Test with 0, 1, 255, 4096 and 65535, and check each result with a calculator.

Expected result

A program that prints the correct binary and hexadecimal form of any number from 0 to 65535.

How it is evaluated

Ways to improve it