有没有办法将整数数字转换为数组(即 45 -> array[0] = 5 ; array [1] = 4)?

Is there a way to convert an integer digits into an array (i.e. 45 -> array[0] = 5 ; array [1] = 4)?

类似这个问题:convert an integer number into an array但是我不知道这个在MIPS中是如何实现的。

当然有办法。您将数字中的每个数字除以 10,并将余数存储在数组中。这可能会完成工作:

.data
array: .word 

.text
.globl main

main:
la $t9, array
li $t1, 45            #number to be stored
li $t2, 10            #base 10

while:
beq $t1, [=10=], end     

div $t1, $t2        # divide by ten, $hi = $t1/$t2, $lo = $t1 mod $t2
mfhi $t3        
mflo $t1
sw $t3, 0($t9)      #store word into array
addi $t9, $t9, 4    #increment array index
j while
end: