Assembly 如何在MIPS程序集中增加地址?
我刚刚开始精益MIPS组装,我正在尝试编写一个简单的Assembly 如何在MIPS程序集中增加地址?,assembly,mips,Assembly,Mips,我刚刚开始精益MIPS组装,我正在尝试编写一个简单的while循环。它将等同于C代码: inta[5] for(i=0;i假设A[] lis $4 .word 4 lis $5 .word 1 add $7, $4, $5 ;$7 = 5 add $6, $0, $0 ;$6 = 0 loop: sw $6, 0($3) add $3, $4, $3 ;point to next "int" add $6, $5, $6 ;add 1 to our counter bne $7, $6, lo
while
循环。它将等同于C代码:
inta[5]代码>
for(i=0;i假设A[]
lis $4
.word 4
lis $5
.word 1
add $7, $4, $5 ;$7 = 5
add $6, $0, $0 ;$6 = 0
loop:
sw $6, 0($3)
add $3, $4, $3 ;point to next "int"
add $6, $5, $6 ;add 1 to our counter
bne $7, $6, loop ;we will stop at 5
这不会只是覆盖循环每次迭代$3中的内容吗?事实上,我把sw语法弄错了。因此,我翻转了2个寄存器。“sw”不会覆盖任何寄存器,它只是写入括号之间的寄存器指向的位置。它不会编译。循环:sw$t1($t0),$t1->”(“:操作数的类型不正确
.data
A: .space 20 #declared 20 bytes of storage to hold array of 5 int
__start:
lw $t0, A #load base address of array
li $t1, 0
loop: sw $t1($t0), $t1
addi $t1, $t1, 4
ble $t1, 20, loop
#continue code or simple exit after this