[理工] [計組] MIPS

看板Grad-ProbAsk作者 (硬體)時間12年前 (2012/07/26 23:49), 編輯推噓0(007)
留言7則, 2人參與, 最新討論串4/8 (看更多)
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 $t0,16($s7) sll $t0,$t0,2 <----- add $t0,$s6,$t0 <----- 這三行的意義不太懂,有請板上高手指教,thank you lw $s0,0($t0) <----- sub $s0 ,$s1,$s0 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 61.227.54.233

07/26 23:55, , 1F
第一行的$s0應該要改成$t0吧
07/26 23:55, 1F
感謝提醒:P

07/27 00:01, , 2F
第1行是t0=B[4], 第2行是t0=B[4]*4
07/27 00:01, 2F

07/27 00:01, , 3F
第3行是將A陣列的位址加上B[4]*4,即A[B[4]]的位址
07/27 00:01, 3F
為什麼B[4]*4,即A[B[4]]的位址呀?

07/27 00:01, , 4F
第4行是將A[B[4]]內容放到f
07/27 00:01, 4F
※ 編輯: hardware 來自: 61.227.54.233 (07/27 00:05)

07/27 00:11, , 5F
假設A的位址即A[0]是0X00,則A[1]的位址是0X04,因為1個整數是
07/27 00:11, 5F

07/27 00:12, , 6F
4個byte
07/27 00:12, 6F

07/27 00:18, , 7F
感謝
07/27 00:18, 7F
文章代碼(AID): #1G4MSYdR (Grad-ProbAsk)
文章代碼(AID): #1G4MSYdR (Grad-ProbAsk)