How can I convert this to mips assembly code
M[][]= {{1, 2, 3, 4},{5, 6, 7, 8},{9, 10, 11, 12},{13, 14, 15, 16}}
should I break this array into two or what? like this?
M1: .byte 1, 2, 3, 4, 5, 6, 7, 8
M2: .byte 9, 10, 11, 12, 13, 14, 15, 16
How can I convert this to mips assembly code
M[][]= {{1, 2, 3, 4},{5, 6, 7, 8},{9, 10, 11, 12},{13, 14, 15, 16}}
should I break this array into two or what? like this?
M1: .byte 1, 2, 3, 4, 5, 6, 7, 8
M2: .byte 9, 10, 11, 12, 13, 14, 15, 16
No, it's single continuous M array of 16 byte values (1-16). The "two MxN dimensions" are faked by the index mapping function fmap(n, m) = n*M + m, and then address of element(n, m) is M + fmap(m, n).
I.e. to fetch M[2, 3] from 4x4 array you calculate offset of element as 2*4 + 3 = 11 (if indices are going from 0 of course, as every decent low level programming language does, eat this pascal!), so this would be element with value 12 (last one in third group).
The computer memory is only "one-dimensional", so any more complex structure has to be mapped to it by the code.