NoBugCodeFarm
2022-06-24 14:29
浏览 13

【提问】MIPS (地址问题)

编程苦手,入站第一天

大家好,我想问一个关于MIPS的问题。当我把一个数值存入array时,程序告诉我地址(我也不太清楚是什么的地址)在”KDATA“。然而我并不知道什么是KDATA,我只知道这地址跳的离谱。 请帮帮我。

代码:

.data
.align 2
correct_solution:    .space 16  _# int correct_solution[GUESS_LEN];_

li    $t0,0          _ # i = 0_
generate_solution__loop:    
bge   $t0,4, generate_solution__epilogue

li    $t5,6
move  $a0,$t5           _ # rand(6)_
jal   rand              #
move  $t1,$v0           _# t1 = rand(6) + 1_
addi  $t1,$t1,1

la    $t2,correct_solution _# correct_solution[i]_
add   $t3,$t0,$t2          # 
sb    $t1,($t3)            _# store bits correct_solution[i]_

addi  $t0,$t0,1
j     generate_solution__loop

报错:
error: segmentation fault
this happened because you tried to write to
the address 0xa86276a1, which is not a valid address to write to
the instruction that failed was:
0x00400180 276 [0xa1690000] sb $t1, ($t3) # sb $t1,($t3) # store bits correct_solution[i]
tip: the address 0xa86276a1 is part of the KDATA segment

img

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

相关推荐 更多相似问题