Accessing bytes in array MIPS -


in mips, have created array using .byte initialized values.

array: .byte 1,2,3,4,5,6,7,8,9 

those values stored in memory 8 bit integers, example:

0x04030201 

how can access individual values in order sum integers? using bit mask way? there easier way it?

you use opcode lb $t, offset($s). works same lw $t, offset($s), loads byte instead of 4-byte word $t.

so let's want load 6th byte of array. do:

la $t0, array  # load array address lb $t1, 5($t0) # 6th byte through offset  # whatever want here 

edit: have lh 2-byte halfwords. also, here's mips instruction reference used answer question: http://www.mrc.uidaho.edu/mrc/people/jff/digital/mipsir.html


Comments