Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer in MIPS code. Using the attached template, update the PrintMouseLocation function to obtain and print the X and Y position of the mouse.

Please answer in MIPS code. Using the attached template, update the PrintMouseLocation function to obtain and print the X and Y position of the mouse. The code the print it is already given and is currently returning 0 and 0 awaiting your implementation to correctly obtain the mouse values. .data CR = ' SPACE = 0x20 BLOCKCHAR = 0xdb NUMBLOCKS = 1 NUMCOLUMNS = 79 NUMROWS = 25 NUMITERATIONS = 50 WIDTH = 79 HEIGHT = 25 windowHandle .word 0 xMessage .asciiz "X: " yMessage .asciiz "Y: " .data mouse: .struct 0xa0000018 flags: .byte 0 mask: .byte 0 .half 0 .word 0 move: .word 0,0 down: .word 0,0 up: .word 0,0 wheel: .word 0,0 wheeldown: .word 0,0 wheelup: .word 0,0 .code .globl main ########################################################################## # DELAY # input: $a1 is the number of times to iterate without doing anythin ########################################################################## Delay: b 2f # branch to label 2 (f = forward from here) 1: # for ( $a1; $a1>0; --$a1) nop # do nothing; ie. delay addi $a1,$a1,-1 # decrement the for loop counter 2: bgtz $a1,1b # branch greater than to label 1 (b = backward from here) jr $ra # return from function call ############################################################################ # InitScreen ############################################################################ InitScreen: li $a0,NUMROWS li $a1,NUMCOLUMNS li $a2,1 syscall $open_cons sw $v0,windowHandle move $a0,$v0 syscall $select_cons jr $ra ############################################################################ # PrintMouseLocation # # Output: # Print the x position of mouse # Print the y position of mouse # ############################################################################ PrintMouseLocation move $v0,$zero move $v1,$zero # v-- YOUR CODE BELOW --v # want the x location in $v0 # want the y location in $v1 # ^-- YOUR CODE ABOVE --^ li $a0,CR syscall $print_char la $a0,xMessage syscall $print_string move $a0,$v0 syscall $print_int li $a0,CR syscall $print_char la $a0,yMessage syscall $print_string move $a0,$v1 syscall $print_int li $a0,CR syscall $print_char jr $ra ############################################################################ # Main ############################################################################ main: jal InitScreen li $t0,NUMITERATIONS loop: jal PrintMouseLocation li $a1,0x00700000 jal Delay addi $t0,$t0,-1 bgtz $t0,loop finished: lw $a0,windowHandle syscall $close_cons syscall $exit

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions