简体   繁体   中英

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).

And it looks like this in register window:

$t0 0x10040000

$t1 0x10040008

$t2 0x10040010

$t3 0x10040018

$s0 0x10040020

$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).

Later on, when I process arrays it messes with addresses and rewrites them instead of writing to the correct ones.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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