Question

mips language In many user applications, there are built in pauses that stop the execution of...

mips language

In many user applications, there are built in pauses that stop the execution of the program until the user hits a key (such as the escape key).

Write a function (and not a complete program) wait_for_esc that features a loop that keeps repeating until the user hits the escape key. You may assume that the keyboard control register can be accessed using memory location 0xFFFF0000 and that the keyboard data register can be accessed using memory location 0xFFFF0004. The ASCII code for the escape character is 27 (base 10).

0 0
Add a comment Improve this question Transcribed image text
Answer #1

PROGRAM:

wait_for_esc:
   lw $t0,0xffff0000
   andi $t0,$t0,0x1       # Isolate ready bit
   beqz $t0, wait_for_esc
  
   # Read the key pressed into $a0
   lbu $a0,0xffff0004
   andi $t0,$a0,27           # Compare the key with ascii value of escape key(27 in decimal)
   beqz $t0,wait_for_esc       # If the key pressed is not the escape key, repeat the process
  
   jr $ra

Please refer to the following screenshot of the program for indentation of the code:

1 wait_for_esc: 2 lw $t0, 0xffff0000 3 andi $t0,$t0,0x1 # Isolate ready bit beqz $t0, wait_for_esc 5 6 # Read the key pressed

Add a comment
Know the answer?
Add Answer to:
mips language In many user applications, there are built in pauses that stop the execution of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT