please help code Wombat 1.1 Write Womba machine language program that converts a
ID: 3724872 • Letter: P
Question
please help code
Wombat 1.1 Write Womba 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 ne. For example, if the conversion is for 8 bits binary then there will be 8 lines of output. In the binary version of your programs that can be executed on the CPUSim simulator, you are also required to write as comments the line number/address, equivalent decimal version of the binary and appropriate comments to explain each line in your program. The decimal version of the program represents each binary line as two decimal values (first value is the opcode - 4 bits second value is the operand/memory address 12 bits). Therefore, each line of your program should be formatted as follows: Binary-number, Semi-colon, Line-number/address, Decimal-opcode, Decimal-operand/address, Comments As an example, suppose you are writing a program to read and display a number. This program could be written as follows: 00110000000000o0: 30 read n into accumulator 00100000000010102: 2 10 store n at location 10 0001000000001010 4: 1 10 load n from location 10 0100000000000000 6: 40 output n 00000000000000008: 0 0 stop 0000000000000000 10: 0 0 storage location for n Submission GuidelinesExplanation / Answer
Your input here has to be: A Decimal Number
Output: It's corresponding value with radix 2 to 8
The psuedocode for the problem is:
1. Load the decimal number-> D
2. Load the radix to which input is to be converted-> b
3. Repeat until the input number >0
3.1. Convert input number to required base by repeatedly dividing it by base and taking remainder-> D/b and take remainder r; the remainder value will be obtained as the value of the carry flag
3.2. Store the remainder value and reverse it to get the final answer or here you can store the value of the carry into a memory location. then increment the memory location to store the value of carry in the next division operation
The logic you require for your code is simple:
Load the values
Perform division
Get the carry value
Store the carry value into a continous memory location
I hope this clears your doubt
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.