Академический Документы
Профессиональный Документы
Культура Документы
lw
$t2, 4($s1)
lw
$t3, 8($s1)
addi
$t3, $t3, -5
add
sw
# h=h-5
$t1, 0($s1)
or
f : $s0, g : $s1, h : $s2
addi $t0, $s2, -5
add $s0, $t0, $s1
little endian
big endian
12
ab
ef
cd
cd
12 ab
ef
sll
$t0, $s3, 2
12 12
# offset
sll
$t1, $s4, 2
# offset
add
# A[i]
add
# A[j]
lw
$t0, 0($t0)
# A[i] -> t0
lw
$t1, 0($t1)
# A[j] -> t1
add
sw
$t2, 32($s7)
addi
$t0, $s6, 4
add
$t1, $s6, $0
sw
$t1, 0($t0)
lw
$t0, 0($t0)
add
0x8000 0000
+ 0xD000 0000
= 0x5000 0000
overflow
A[1]=&A[0]
0x8000 0000
- 0xD000 0000
= 0xB000 0000
Right result
0x8000 0000
0x5000 0000
+ 0xD000 0000
+ 0x8000 0000
= 0x5000 0000
= 0xD000 0000
Overflow
But if you we want to make answer from this question. we can get answer as below.
, First
Overflowed,
44 MOD 32 = 12
, Second
sll $t2, $t0, 44
= 0xAAAAA000
all the digits in $t2 are filled with zeros because it is shifted more than 32 bit
or $t2, $t2, $t1
andi $t2, $t2, 0xFFEF # $t2= $t2 & 0x0000FFEF = 0x15555555 & 0x0000FFEF = 0x00005545
$t1, 8193
# or ))
lui
$t1, 0x2001
ori
# or ))
ori