We are using ARM200 to learn assembly language. I have a portion of memory with 32 integers filling it. I need to be able to print out these 32 integers to the screen. I can
Since you're learning (ie, possible homework), I'll give general advice only.
Let's say you have the number 247 and you wanted to print out the three digits of it, one by one.
How can you get the hundreds digit 2
from 247
and leave 47
for the next iteration?
Put that value into a temporary variable and set a counter to zero. Then, while the temp value is greater than 99, subtract 100 from it and add 1 to the counter.
This will give you a counter of 2
and a temp value of 47
. Use the 2
to output your digit (you state you can already do this).
Now move on to tens.
Set the counter back to zero.
Then, while the temp value is greater than 9, subtract 10 from it and add 1 to the counter.
This will give you a counter of 4
and a temp value of 7
. Use the 4
to output your digit.
Finally, units.
Use the final remainder 7
to output the last digit.
Here's some assembler-like pseudo-code I used in another answer (slightly modified) to do a similar thing.
val = 247
units = val
tens = 0
hundreds = 0
loop1:
if units < 100 goto loop2
units = units - 100
hundreds = hundreds + 1
goto loop1
loop2:
if units < 10 goto done
units = units - 10
tens = tens + 1
goto loop2
done:
if hundreds > 0: # Don't print leading zeroes.
output hundreds
if hundreds > 0 or tens > 0:
output tens
output units
;; hundreds = 2, tens = 4, units = 7.
And one other thing, all this stuff needs to go into subroutines so that you can re-use them. Having thirty-two copies of that algorithm above converted to assembly would be a very tedious piece of code.