Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8131249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:02:11+00:00 2026-06-06T09:02:11+00:00

I am studying a MIPS code that uses procedure but I can not understand

  • 0

I am studying a MIPS code that uses procedure but I can not understand what is the purpose of stack (sp) and frame pointer (fp).

For example the code I study have this below. It prints the all the numbers before the number you entered, e.g. 3. 3,2,1,0 and shows how much stack size it used. In this example it used 16. I changed the -4 to -8 and I got an error.
However, I noticed some other codes that uses -8.

The question is what am I missing?

proc:
    addi $sp,$sp,-4     # 
    sw   $ra,0($sp)     # push $ra  
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T09:02:14+00:00Added an answer on June 6, 2026 at 9:02 am

    Push the return address onto the stack before calling the function. That is what the code does. -4 means “allocating” 4 bytes on the stack by moving the stack pointer up, so that the return address can be written.

    The explanation above assumes the normal usage of the registers.

    I cannot conclude on what the -8 does until I see the code. But it is likely reserving space for the argument to the function.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i studying TDateTime functions and procedure, but not found something that allow me to
while studying some security things, there was a question that one can guess the
I am studying the MIPS assembly language and came across this example in the
Studying C conversions I found a paragraph about Integer promotions that I haven't understand
Studying Haskell, i'm trying to code a function takeIf that given a condition and
When studying Java I learned that Strings were not safe for storing passwords ,
After studying TCP/UDP difference all week, I just can't decide which to use. I
While studying the Collection API, we find that some methods ( add , remove
When studying a snippet of unknown Python code, I occasionally bump into the varName.methodName()
I was studying an open source code where I came across the following line

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.