我的程序应该执行以下操作: - 从用户 (x) 连续获取一个整数, - 在字符串中的 x 位置打印字符。- 当用户输入 0 时程序退出。
.text
.globl __start
__start:
li $s3,20 #string length
start: li $v0,5
syscall
move $s0,$a0 #integer now in $a0
beq $s0,$zero,exit
li $s1,0 #counter is 0
la $s2,str #address of string now is $s2
loop:lbu $t1,0($s2) #choosing char of string
addi $s1,1 #increment counter by 1
addi $s2,1 #next char
beq $s1,$s0,print #is the char at the position we entered?
j loop
print: lbu $a0,0($t1) #<------------#
li $v0,11
syscall
j start
exit: li $v0,10
syscall
.data
str: .asciiz "abcdefghijklmnopqrst"
当我尝试运行我标记的行时,我不断收到:“PC = 0x00400034 发生异常”和“数据堆栈读取中的错误地址:0x ...”。