简体   繁体   English

Word存储在MIPS / MARS中动态分配的数组中的错误地址中

[英]Word stores into wrong address in dynamically allocated array in MIPS/MARS

I dynamically allocate 48 bits using syscall 9 and then iterate through it setting t0-t3 and s0-s1 to different addresses (like arrays of 2 elements). 我使用syscall 9动态分配48位,然后遍历它,将t0-t3和s0-s1设置为不同的地址(如2个元素的数组)。

And it looks like this in register window: 在注册窗口中看起来像这样:

$t0 0x10040000 $ t0 0x10040000

$t1 0x10040008 $ t1 0x10040008

$t2 0x10040010 $ t2 0x10040010

$t3 0x10040018 $ t3​​ 0x10040018

$s0 0x10040020 $ s0 0x10040020

$s1 0x10040028 $ s1 0x10040028

Then I proceed to get user input to put them into the arrays. 然后,我继续获取用户输入,以将其放入数组。 When I store first input with sw $v0, ($t0) it goes into Value(+4) in debugger window not into Value(+0). 当我用sw $v0, ($t0)存储第一个输入时sw $v0, ($t0)它将进入调试器窗口中的Value(+4)而不是Value(+0)。

Later on, when I process arrays it messes with addresses and rewrites them instead of writing to the correct ones. 稍后,当我处理数组时,它会弄乱地址并重写它们,而不是写入正确的地址。

它将数字存储在正确的地址中,问题是在MARS中显示了错误的数字(我调试它只是打印出数字)

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

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