首页 > 解决方案 > MIPS 错误的 MARS 仿真器:地址超出范围 0x20000000

问题描述

我不确定我在哪里搞砸了,但我正在为 MIPS 使用 MARS 模拟器,并且在我的

lw $s6, 0($s7) #s6 now holds c[i]线。

这是我的错误:

Error in C:\Programming\mips1.asm line 14: Runtime exception at 0x00400020: address out of range 0x20000000

Go: execution terminated with errors.

.text
.globl main

main:
    add $s0, $zero, $zero
    lui $s3, 0x2000
        addi $s5, $zero, 100
        addi $sp, $sp, -8
Loop:
    slt $t2, $s0, $s5
    beq $zero, $t2, Exit
    sll $s7, $s0, 2
    add $s7, $s7, $s3 #s7 is now the address of c[i]
    lw $s6, 0($s7) #s6 now holds c[i]
    slt $t3, $s0, $s1 #set t3 if i is less than a
    bne $zero, $t3, Else
    sw $s2, 0($s7) #stores b into c[i] 
    add $s0, $s0, 1
    j Loop
Else:   add $s2, $zero, $s6
    add $s0, $s0, 1
    j Loop
Exit:   addi $sp, $sp, 8

li $v0, 10
syscall

标签: mips

解决方案


我解决了它,结果我需要一个较低的地址才能使其成为堆的一部分。MARS 堆从 0x10040000 开始并向上移动。

我将 0x2000 更改为 0x1005,它在 MARS 中工作


推荐阅读