Stack om Mips

This topic contains 1 reply, has 2 voices, and was last updated by  ChrisImgtec 3 years, 5 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #31688


    As the version of Mips that I use don’t support the push/pop instructions, I should implement them.
    So that, if i have many registers to push (pop obviously), how should I proceed?
    If I want to push 2 registers for example, should I make the following code:
    addiu $SP, $SP, -8
    sw $re1,0($sp)
    sw $re2,4($sp)
    addiu $30,$SP,0 (move instruction)
    The -8 in this case is th number of registers ti push*4,is it usually the case even if we have independent pushes in one application(many calls of push function) ?



    Assuming $re1 is just sudo code for an actual register then your code is correct. (I also assume you have a reason to store the frame pointer, for that you could have also used sw $sp, 0($fp).

Viewing 2 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic.