Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Write Wombat1 machine language program that converts a number into a radix representation. For example, a number converted into radix 2 or radix 3. The program should be able to convert a decimal number into any radix from 2 to 8. Your program should take two inputs. The first input will be the number to convert (should be positive) and the second input will be the radix. Note: in CPUSIM each output will be in one line. For example, if the conversion is for 8 bits binary then there will be 8 lines of output.

What I have tried:

0011000000000000 ;0  3  0   read number into acc
1011000000000000 ;2  10 0   if acc < 0 jump to loc 0, read again
0010000000101110 ;4  2  46  store at loc 
0011000000000000 ;6  3  0   read radix number
1011000000000110 ;8  10 6   if acc < 0, jump to loc 6, read again
0010000000110000 ;10 2  48  store at loc 
0001000000101110 ;12 1  46  load number to acc
1000000000110000 ;14 8  48  divide number by radix
Posted
Updated 15-Mar-18 2:26am
v3
Comments
Patrice T 15-Mar-18 8:21am    
And you have some code or you just want us to do your homework?

1 solution

I suggest you to first write the symbolic code (assembly) and then, once your're confident it could work, transform it in machine language.
Moreover, start simple: write, at first, a simple converter to radix 2 representation.
 
Share this answer
 
v2

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