将最多32个int存储到数组MIPS中

时间:2015-04-10 15:08:10

标签: mips mips64 smips

我正在尝试将类型int的数量存储到MIPS中的数组中,这是我到目前为止所做的,但很明显,因为我没有足够的寄存器来这样做,所以效率不高。最后,我几乎整理了数组。有什么帮助吗?

.data   
array:  .space  32              #saves space for array with undefined values
comma:  .asciiz ","
prompt: .asciiz "Enter numbers (amount must be to a power of 2) :"
.text   

.globl main

main:

#addi $s5, $zero, 0     #stores zero into $s5
la $a1,array



li $v0,4            #Prompt for user input
la $a0, prompt          #Displays message
syscall

li $v0, 5           # read integer 
syscall 
add $s0,$v0,$zero       #store input into $s0
sw $s0, array           #stores into memory

li $v0, 5           # read integer 
syscall 
add $s1,$v0,$zero
sw $s1, array +4

li $v0, 5           # read integer 
syscall 
add $s2,$v0,$zero
sw $s2, array +8

li $v0, 5           # read integer 
syscall 
add $s3,$v0,$zero
sw $s3, array +12

li $v0, 5           # read integer 
syscall 
add $s4,$v0,$zero
sw $s4, array +16

等...

0 个答案:

没有答案