Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 3 - PRINTDEC - 4 5 Points - Print a 1 6 - bit number as decimal. 1 . Use DIV and MOD from

Part 3- PRINTDEC -45 Points - Print a 16-bit number as decimal.
1. Use DIV and MOD from previous steps in this assignment.
NOTE that the DIV and MOD algorithms listed above will not work with negative values.
When testing only use R1 and R2 values which are less than x8000 hexadecimal or less than 32768 in
decimal. For this assignment, you can assume R0 will never contain a value greater than x7FFF when
calling PRINTDEC.
2. A 16-bit number will be stored in R0. You will have to figure out each digit one at a time and print
each.
3. DO NOT PRINT leading zeros. Loop until a non-zero digit is found and then print the rest of the digits.
YOU CAN NOT ignore all zeros. Only ignore leading zeros.
4. DO NOT PRINT a newline at the end.
5. Your program should print a single 0 if R0 is 0.
Main should look like this when submitting part 3.
.orig x3000
JSR PRINTDEC
JSR PRINTDEC
HALT
Assume you have a number like 12345 in R0.
Divide 12345 by 10000 to get 1, add 48 and print it.
Divide 12345 by 1000 to get 12. Mod 12 by 10 to get 2, add 48 and print it.
Divide 12345 by 100 to get 123. Mod 123 by 10 to get 3, add 48 and print it.
Divide 12345 by 10 to get 1234. Mod 1234 by 10 to get 4, add 48 and print it.
Divide 12345 by 1 to get 12345. Mod 12345 by 10 to get 5, add 48 and print it.
Assume you have a number like 123 in R0.
Divide 123 by 10000 to get 0. Ignore it.
Divide 123 by 1000 to get 0. Ignore it.
Divide 123 by 100 to get 1. Mod 1 by 10 to get 1, add 48 and print it.
Divide 123 by 10 to get 12. Mod 12 by 10 to get 2, add 48 and print it.
Divide 123 by 1 to get 123. Mod 123 by 10 to get 3, add 48 and print it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2015 Porto Portugal September 7 11 2015 Proceedings Part 2 Lnai 9285

Authors: Annalisa Appice ,Pedro Pereira Rodrigues ,Vitor Santos Costa ,Joao Gama ,Alipio Jorge ,Carlos Soares

1st Edition

3319235249, 978-3319235240

Students also viewed these Databases questions