简体   繁体   English

MIPS 地址超出范围 (MARS); 初学者

[英]MIPS Address out of range (MARS); Beginner

I'm trying to understand some code.我试图理解一些代码。 I'm still at the very beginning of MIPS.我还处于 MIPS 的初期。 I tried to get it run on Mars to understand whats happening step by step.我试图让它在火星上运行,以逐步了解正在发生的事情。 However it's stops at line 6: Runtime exception at 0x0040000c (refers to line 6): address out of range 0x000003ec.但是它在第 6 行停止:0x0040000c 处的运行时异常(参考第 6 行):地址超出范围 0x000003ec。

I tried to find a solution by looking throught other posts here, however wasn't able to identify the problem.我试图通过查看此处的其他帖子来找到解决方案,但是无法确定问题所在。

add  $t6, $t0, $t0
addi $t4, $t0, 0x7
andi $t3, $t4, 0x4
loop:
lw   $t2, 0x3e8($t3)
add  $t6, $t3, $t6
addi $t5, $t4, 1
sub  $t1, $t2, $t6
bne  $t5, $t6, loop
sw   $t6, 0x400($t1)

If you could hepl me out I would really appreciate it!如果你能帮我解决问题,我将不胜感激!

This strange code is either going to load from 0x3e8 or 0x3ec, depending on what is in $t0 to start.这个奇怪的代码要么从 0x3e8 或 0x3ec 加载,这取决于$t0中的内容。

Both of those are unusually low memory locations, which don't store anything of interest, and are typically protected to detect program faults.这两个都是异常低的内存位置,不存储任何感兴趣的东西,并且通常受到保护以检测程序错误。

Generally speaking we want to see memory addresses in certain ranges that are assigned to various kinds of content.一般来说,我们希望看到分配给各种内容的特定范围内的内存地址。 While not at all comprehensive, the following should give some idea of expectations for a simple program in MARS:虽然并不全面,但以下内容应该对 MARS 中的简单程序的期望给出一些想法:

  • code in the range of 0x00400000 to 0x004FFFFF, 0x00400000 到 0x004FFFFF 范围内的代码,
  • global data in the range of 0x10010000 to 0x1003FFFF, 0x10010000 到 0x1003FFFF 范围内的全局数据,
  • heap data in the range of 0x10040000 to 0x1FFFFFFF,堆数据在 0x10040000 到 0x1FFFFFFF 范围内,
  • stack data in the range of 0x70000000 to 0x7FFFFFFF堆栈数据在 0x70000000 到 0x7FFFFFFFF 范围内

Addresses wildly outside of the ranges designated for valid content will usually (but not always) cause a fault, because these addresses are not valid, so something in the program went wrong — the program is trying to access memory that does not belong to valid data or instructions (eg global, heap, stack, or code)超出为有效内容指定的范围的地址通常会(但并非总是)导致错误,因为这些地址无效,因此程序中出现错误——程序试图访问不属于有效数据的内存或指令(例如全局、堆、堆栈或代码)

You will have to debug the larger code to understand what it is trying to do and see where it is going wrong in that, and thus why this fault might be happening.您将不得不调试较大的代码以了解它正在尝试做什么并查看它在哪里出错,因此为什么可能会发生此错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM