Imagine that I have a function in C that has 5 parameter.
sum(n1,n2,n3,n4,n5);
In assembly. I get the first four parameter from registers 4 to 7 and the last parameter is acceded like:
lw $8, 16($29)
First question
If lw $8, 16($29)
puts n5 in register $8, why doesn't this
lw $9, 0($29)
lw $10, 4($29)
lw $11, 8($29)
lw $12, 12($29)
puts n1 to n4 in registers $9 to $12?
Second question
Since the parameters in sum(n1,n2,n3,n4,n5);
are somewhere stored in memory and in assembly, the first parameter is in $4
how can I get the memory address of $4
to $7
?
If i do this:
.data
array: .word 3,4,2,6,12,7,18,26,2,14,19,7,8,12,13
.text
main:
li $8,1
la $9,array
the last instruction puts the address location of my array in $9
. If I do
main:
li $4,1
la $9,0($4)
The value on $9
is still 1 and not the address of $4