Stack push operation in MIPS Assembly

5.7k views Asked by At

In MIPS Assembly, we can declare stack and can perform push operation in it by using the following simple code:

sw $t0,0($sp)

My question is: can I use a register in place of 0 (any alternative?). Because I want to increment in the register and to perform stack operation in a special flow.

Supposed operation is:

sw $t0,$s0($sp)

addi $s0,$s0,1

Thanks in advance for help.

1

There are 1 answers

1
Lap On BEST ANSWER

it's very simple.As

la $t0,$sp

loop:

sw $t1,0($sp)
addi $sp,$sp,4


conditon

exit:

each time there is updating of $sp register.