Run The program in FASM.exe

0 comments

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.

Algorithm to convert Value to binary:
(1) set Count to 0
(2) AND Value with 128 (binary 10000000) and store into Temp
(3) if result is zero, output “0”
(4) if result is not zero, output “1”
(5) shift Temp left
(6) increment Count
(7) if Count <= 8, jump to step (2)

Algorithm to convert Value to hexadecimal:
(1) shift Value right 4 digits and store into Temp
(2) if Temp <=9, print Temp
(3) if Temp >=10, add 55 to Temp and print the ASCII character
(4) AND Value with 240 (binary 00001111) and store into Temp
(5) if Temp <=9, print Value
(6) 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

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}