推 ddczx:第一行 # $t0 =($s7(B的base adress) + 16)這個位址指到的值 07/27 00:15
※ 引述《hardware (硬體)》之銘言:
: Q: f=g-A[B[4]]
: Assume the variable f,g,h,i and j are assigned to registers $s0,$s1,$s2,$s3
: ,$s4 respectively.the base adress of the arrays A and B are in registers
: $s6,$s7
: A:
: MIPS
: lw $s0 16($s7)
: sll $t0,$t0,2 <-----
: add $t0,$s6,$t0 <----- 這三行的意義不太懂,有請板上高手指教,thank you
: lw $s0,0($t0) <-----
: sub $s0 ,$s1,$s0
我的想法是如下
lw $t0,16($s7) # $t0 = $s7(B的base adress) + 16
sll $t0,$t0,2 # $t0 << 2 ; $t0的值左位移2bit(即乘4功能) 算出A[B[4]]的位址
add $t0,$s6,$t0 # $t0 = $s6 + $t0 這是將A[B[4]] 與 A的base adress相加
lw $t1,0($t0) # 取出A[B[4]]的值
sub $s0,$s1,$t1 # 算出g-A[B[4]]的值給f暫存器
有錯的請還麻煩各位更正一下。
感恩。
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.187.3.183