Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Assembly MIPS程序集更改整数,然后在该位置将其打印出来_Assembly_Mips - Fatal编程技术网

Assembly MIPS程序集更改整数,然后在该位置将其打印出来

Assembly MIPS程序集更改整数,然后在该位置将其打印出来,assembly,mips,Assembly,Mips,我希望能够使用函数传递数组、大小和值。在函数中,我希望数组的第一个位置等于我们传递的值 伪代码中的等价物是 function (array[10], size, value); array[0] = value; print(array[0]); 我在mips中拥有的: .data array: .space 12 # my array of integers size: .word 3 # size of array start: .word 5 # starter

我希望能够使用函数传递数组、大小和值。在函数中,我希望数组的第一个位置等于我们传递的值

伪代码中的等价物是

function (array[10], size, value);
    array[0] = value;
    print(array[0]);
我在mips中拥有的:

.data
array: .space 12 # my array of integers
size:  .word  3  # size of array
start: .word  5  # starter value

.text

main:

    la  $a1 array # loads $a1 with array buffer
    la  $a2 size  # loads $a2 with size of the user input
    la  $a3 start # loads $a3 with starter value
    jal fillArray

    li $v0 10
    syscall

fillArray:

    # this is where we make "array" at position 0 equal to "start"
    # this is where we print out "array" at position 0

    li $v0 1
    syscall

    jr $ra

我真的很难理解函数和数组,因此非常感谢您的帮助。

解决了这个问题。答案如下:

sw $a3 0($a1) # saves $a3(start) to position 0 of array
您可以执行
添加$a1$ai 4
以增加数组