go to previous page   go to home page   go to next page highlighting

Must the nop follow the jal?

Answer:

Yes. (Assuming a real MIPS chip with branch delays.) With QTSPIM branch delays can be turned off.


Maximum of Three Expressions

For the next example, the main program asks the user for integers x and y and writes out the maximum of x*x, x*y, and 5*y. Look ahead to page 22 to see main.

main uses this sub-task:

Write a subroutine that returns the maximum of three expressions: x*x, x*y, and 5*y for integer arguments x and y. The integers use two's complement representation. Use stack-based linking.

With our stack-based linkage convention this is:

Subroutine maxExp

  Input:   $a0 -- x, a two's complement integer
           $a1 -- y, a two's complement integer
           
  Returns: $v0 -- the maximum of x*x, x*y, or 5*y

QUESTION 15:

Can this program use the subroutine maxInt?


go to previous page   go to home page   go to next page