Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Quick MIPS question regarding multiplication

$
0
0
Hi; I know I have to multiply a register's value by 4, then add it to the address of an array to get the address of the [register's value]th element. We were taught to do the multiplication this way:

add $t0, $t0, $t0
add $t0, $t0, $t0

($t0 stores the # of the element)

However, my professor insists that we write code using as few instructions as possible. Thus, could I change the above two lines to:

sll $t0, $t0, 2

Viewing all articles
Browse latest Browse all 51036

Trending Articles