{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COE 308 - Programs - whose address is in register Rs(PC =...

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Programs do input/output through system calls MIPS provides a special  syscall  instruction To obtain services from the operating systemMany services are provided in  the SPIM and MARS simulators Using the  syscall  system services Load the service number in register $v0 Load argument values, if any, in registers $a0, $a1, etc. Issue the  syscall  instructionRetrieve return values, if any, from result registers Suppose we call procedure swap as:  swap(a,10)  Pass  address  of array  and  10  as argumentsCall the procedure swap saving  return address  in  $31 = $ra Execute procedure swap Return control to the point of origin (return address) AL (Jump-and-Link) used as the call instructionSave return address in  $ra = PC+4  and jump to procedure Register  $ra = $31  is used by  JAL  as the  return address JR (Jump Register) used to return from a procedureJump to instruction 
Image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: whose address is in register Rs (PC = Rs) JALR (Jump-and-Link Register)Save return address in Rd = PC+4, andJump to procedure whose address is in register Rs (PC = Rs) Can be used to call methods (addresses known only at runtime Parameter passing in assembly language is different More complicated than that used in a high-level language In assembly languagePlace all required parameters in an accessible storage area Then call the procedure Two types of storage areas usedRegisters: general-purpose registers are used (register method) Memory: stack is used (stack method) Two common mechanisms of parameter passing Pass-by-value: parameter value is passedPass-by-reference: address of parameter is passed...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern