Writing a function in MIPS with global variables?

frogger:
    jal teechar
    jal update_frog
    lw $t0,game_indicator
    li $t0, 0

Ok, this is a feature. I have teechar and update_frog functions fully written and working. I understand the first two bullets, but not sure about the last two. How to write the last two bullets in MIPS?

HERE FUNCTION Instructions:

Write the frogger function of the MIPS function, which takes no arguments and returns a character (to make testing easier). It performs the following actions:

  • Call your teechar to read and echo character c.
  • Call update_frog (c).
  • If c is not equal to zero, save c in a global variable to indicate that the game is over and how to do it. (Of course, you must initialize this global variable to zero.)
  • Refund c.

Here is my code:

frogger:
    jal teechar
    jal update_frog

Sorry, I'm just having problems with how to do this :(

+3
1

, . , , c frogger, .

, !

+1

All Articles