Is it possible for a subroutine to comply with the WRAMP ABI conventions without decrementing/incrementing the stack pointer $sp at all?Question 3Select one:a.No.b.Yes, provided that it only modifies registers that are not being used elsewhere in the program.c.Yes, but it would have to return immediately without executing any instructions other than "jr $ra".d.Yes, provided that it does not modify any registers except $1, and does not call further subroutines.
Question
Is it possible for a subroutine to comply with the WRAMP ABI conventions without decrementing/incrementing the stack pointer ra".d.Yes, provided that it does not modify any registers except $1, and does not call further subroutines.
Solution
The answer is a. No. The WRAMP ABI (Application Binary Interface) conventions require that the stack pointer $sp be decremented/incremented when entering/exiting a subroutine. This is to ensure that the stack, which is used for storing return addresses and local variables, is correctly maintained. If a subroutine did not modify the stack pointer at all, it would not be following the WRAMP ABI conventions.
Similar Questions
In what situations must $1 remain unchanged by a subroutine?Question 13Select one:a.Only if the subroutine does not have a return value.b.Only if the subroutine calls other subroutines.c.Always. Conventions dictate that all registers are not modified by a subroutine.d.Never. Any subroutine is free to modify $1.
Could subroutines use a dedicated section of memory (allocated in .data or .bss) for backing up and restoring register values, instead of using the stack?Question 1Select one:a.Not possible.b.Yes, but it is impossible to use this method and also use the stack to pass parameters to any functions called.c.Yes, this would work fine but it requires more work.d.Yes, but this would only work for a small number of registers because .data and .bss are smaller than the stack segment.
If a WRAMP subroutine takes three parameters, what will the stack pointer be pointing at when that subroutine is first entered (i.e. before any instructions have been executed)?Question 11Select one:a.The first parameter.b.The last (third) parameter.c.The return address.d.The first instruction.
For an assembler implementation of the routine that is written according to the WRAMPApplication Binary Interface (ABI):int max(int a, int b)that returns the maximum value stored in parameters a and b and uses the general purposeregisters $3 and $4 to determine that answer, but makes no further subroutine calls itself,fill out the diagram below showing the state of the stack-frame just before calling max()where parameter a is value 1, parameter b is value 2, register $3 has value 3 and register $4has value 4. Note, not all of these values are necessarily on the stack when max() is called.(2 marks)+0+1+2+3+412
ssume that a suitable stack frame has already been created, and you are preparing to call another subroutine. Which WRAMP assembly instruction would place the first parameter onto the stack?Question 4Select one:a.push $1b.sw $sp, 0($1)c.push $spd.sw $1, 0($sp)
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.