Question: The program shown converts a binary number to two decimal digits. The binary number is loaded from memory at the location N, and the two

 The program shown converts a binary number to two decimal digits.

The program shown converts a binary number to two decimal digits. The binary number is loaded from memory at the location N, and the two decimal digits that are extracted from N are stored into memory in two bytes starting at the location Digits. For the value, N = 76 (0x4c) shown in the figure, the code sets Digits to 00000706. Make sure that you understand how the code works. Then, extend the code so that it converts the binary number to four decimal digits, supporting decimal values up to 9999. You should modify the DIVIDE subroutine so that it can use any divisor, rather than only a divisor of 10. Pass the divisor to the subroutine in register r5. If you run your code with the value N = 9876 (0x2694), then Digits should be set to 09080706./* Program that converts a binary number to decimal */.text .global _start _star: movie r4, N addition r8, r4, 4//r8 points to storage location//r4 loads N//parameter for DIVIDE is in r4 ldw r4, (r4) call DIVIDE stb r3, l(r8) stb r2, (r8) END: br END/* Subroutine to perform the integer division r4/10 *//* Returns: quotient in r3, and remainder in r2 */ The program shown converts a binary number to two decimal digits. The binary number is loaded from memory at the location N, and the two decimal digits that are extracted from N are stored into memory in two bytes starting at the location Digits. For the value, N = 76 (0x4c) shown in the figure, the code sets Digits to 00000706. Make sure that you understand how the code works. Then, extend the code so that it converts the binary number to four decimal digits, supporting decimal values up to 9999. You should modify the DIVIDE subroutine so that it can use any divisor, rather than only a divisor of 10. Pass the divisor to the subroutine in register r5. If you run your code with the value N = 9876 (0x2694), then Digits should be set to 09080706./* Program that converts a binary number to decimal */.text .global _start _star: movie r4, N addition r8, r4, 4//r8 points to storage location//r4 loads N//parameter for DIVIDE is in r4 ldw r4, (r4) call DIVIDE stb r3, l(r8) stb r2, (r8) END: br END/* Subroutine to perform the integer division r4/10 *//* Returns: quotient in r3, and remainder in r2 */

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!