Either submit the source code file (.asm) on Ecampus under the "Submit Homework" menu option, or demo the programs to the instructor during lab.

Using the flat assembler (fasm), write a program that converts an 8-bit integer to binary and hexadecimal using bitwise operators.  Do not use external functions.  You may use the algorithm below.

Ask user to enter a number 0 - 255 and store into Num

Algorithm to convert Value to binary:
(1)  Set Count to 0. Move Num into a variable named Temp
(2)  Move Temp into EAX then AND EAX with 128 (binary 10000000)
(3)  if result is zero, output "0"
(4)  if result is not zero, output "1"
(5)  shift Temp left one digit
(6)  increment Count

Algorithm to convert Value to hexadecimal:
(1)  Move Num into a variable named Temp
(2)  shift Temp right 4 digits to isolate left 4 digits
(3)  if Temp <=9, print Temp
(4)  if Temp >=10, add 55 to Temp and print the ASCII character
(5)  Move Num into a variable named Temp
(6)  AND Temp with 15 (binary 00001111) to isolate right 4 digits
(7)  if Temp <=9, print Value
(8)  if Temp >=10, add 55 to Temp and print the ASCII character

Example output
This x86 assembly program converts an integer to binary and hex.

Enter an integer from 0 - 255: 73
Binary: 01001001
Hex:    49