assembly - array indexing with MIPS -
i have bit of trouble array indexing in mips. lets have following c code:
void main() { . . int[2] a; # or other length . . a[1] = 7; # or other number . . }
lets know 'a' offset frame pointer example 12, that:
lw t0, -12($fp)
gives me base address of 'a'. lets array access index value (in case 1) stored in $t1. don't is. how can store 7 in a[1]? looking like:
mul $t1, $t1, -4 # since each integer takes 4 bytes addi $t1, $t1, -12 # t1 = exact offset $fp a[1] li $t2, 7 # t2 = 7 sw $t2, $t1($fp)
the problem last operation illegal (despite integer array indexing mips assembly). how can this? thank
Comments
Post a Comment