Question

For example, I want to print this number A0090000(16) in unsigned decimal number in MIPS. So the print result should be 2684944384(10). But I got stuck because I only know the assembly code to print signed numbers.

The code is like this:

li    $v0, 1    #System call code for print_int
li    $a0, 5    #integer to print
syscall

So if I put the A0090000(16) value instead of '5' in that code, it will print a minus decimal value(since MSB is 1), which is -1610022912(10) but I want to have the result 2684944383(10), which is read as an unsigned number.

How can I do that?

Was it helpful?

Solution

Fill a string with the digits of your number, in reverse order, by successively dividing the value by 10 (unsigned) and adding the remainder's digit onto the start of your string; then print the string.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top