Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i am new to computer science and came across this question that one needs to convert a decimal number to any base like binary, hexadecimal,ASCII in assembly language microprocessor 8086

What I have tried:

i have tried to convert a decimal to binary but i don't know how to put them together so that i can be able to ask the system, input a number then give options on what base to convert it to.
Please help me out here.
Posted
Updated 17-Mar-19 22:47pm

1 solution

Converting a binary integer value to a character representation follows the basic path:
Allocate a string array long enough to hold any number of digits
While the number is greater than zero
Get the remainder of the number divided by the base
Convert the resulting value to a character (add '0' for decimals)
Add the resulting character to the next position of the string array
Divide the number by the base ignoring any remainder
Repeat the While loop
When the number has been reduced to zero, display the string, in reverse order.

You can see how this works by emulating this algorithm manually using paper and pencil.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900