简体   繁体   中英

Loading Values with $zero in MIPS

I'm having some trouble understanding how 'n($zero)' is used in register storage. In the question below, since each hex is 4 bits what value is '6($zero)' which is being loaded into $s1?

$s1 = A1B2C3D4
$s2 = 5A6B7C8D

sw $s1, 4($zero)
sw $s2, 8($zero) 
lw $s1, 6($zero)

What is the result of $s1 after this process?

lw $s1, 6($zero) loads from absolute address 0+6 = 6 and thus faults, unless you're on a modern enough MIPS that unaligned loads are allowed.

If so, the result depends on which endianness mode your MIPS CPU is operating in. eg MARS simulates a little-endian MIPS, where you would get the low half of the store to address 8 , and the high half of the store to 4 . But it's common for MIPS CPUs to run in big-endian mode.

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