作者Lewis2000 (黑)
看板C_and_CPP
标题[问题] 用C语言表达MIPS语言
时间Fri Jan 30 04:27:56 2009
请教一个题目:
Let us give the following MIPS assembly code
Loop: add $t1, $s3, $s3
add $t1, $t1, $t1
add $t1, $t1, $s5
lw $t0, 0($t1)
add $s1, $s1, $t0
add $s3, $s3, $s4
bne $s3, $s2, Loop
暂存器$s1,$s2,$s3,$s4分别为g,h,i,j
A为array且$s5存放指向A之基底位址
(A is an array of 100 elements and the base of the array A is in $s5)
解答:
Loop: g=g+a[i]
i=i+j ;
if(i!=h) go to Loop;
我想请教的是为什麽是用g=g+a[i]来表示
MIPS语言$s1 <-- M[4i+$s5] 的部份。
对於阵列的观念跟使用不太清楚,麻烦
各位大大能替我解答 <(_._)>
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 118.160.70.163
1F:→ MOONRAKER:因为MIPS是byte address, 阵列中元素长度都是4-byte 01/30 23:20