Question: Below is square.asm template Question 3: Testing for a Perfect Square (30 marks) Write a MIPS subroutine, square', which takes as its input a single

Below is square.asm template Question 3: Testing for a Perfect Square (30Below is square.asm template

marks) Write a MIPS subroutine, square', which takes as its input a

Question 3: Testing for a Perfect Square (30 marks) Write a MIPS subroutine, square', which takes as its input a single argument that is an integer. The subroutine determines if that integer is a perfect square and if so, it returns a value of 1. If it is not, it returns a value of 0. Include a 'main' procedure to test this subroutine. The main' procedure should prompt the user to enter an integer, using an appropriate syscall. It should then read in that integer and call the subroutine, passing this integer as an argument. Finally, it should generate an appropriate print statement to indicate whether the input integer is a perfect square (or not). You are given a template square.asm file to work with. square.asm # This program illustrates an exercise of determining whether an integer is a perfect square. # The subroutine 'square' return 1 if the input is a perfect square or o otherwise, using an appropriate return register. # The 'main' program should test the subroutine by first prompting the user for an integer to test, and then # calling the subroutine with that integer as an argument. Determining on the outcome of the test, the # 'main' program should generate an appropriate print statement. # Feel free to add additional entries as you need them in the .text or .data segments. # Make sure that your 'main' program terminates gracefully. # Be sure to comment your code. Use proper register conventions ! .data prompt: .asciiz "Enter a positive integer: ", .text .globl main main: jal square square: Question 3: Testing for a Perfect Square (30 marks) Write a MIPS subroutine, square', which takes as its input a single argument that is an integer. The subroutine determines if that integer is a perfect square and if so, it returns a value of 1. If it is not, it returns a value of 0. Include a 'main' procedure to test this subroutine. The main' procedure should prompt the user to enter an integer, using an appropriate syscall. It should then read in that integer and call the subroutine, passing this integer as an argument. Finally, it should generate an appropriate print statement to indicate whether the input integer is a perfect square (or not). You are given a template square.asm file to work with. square.asm # This program illustrates an exercise of determining whether an integer is a perfect square. # The subroutine 'square' return 1 if the input is a perfect square or o otherwise, using an appropriate return register. # The 'main' program should test the subroutine by first prompting the user for an integer to test, and then # calling the subroutine with that integer as an argument. Determining on the outcome of the test, the # 'main' program should generate an appropriate print statement. # Feel free to add additional entries as you need them in the .text or .data segments. # Make sure that your 'main' program terminates gracefully. # Be sure to comment your code. Use proper register conventions ! .data prompt: .asciiz "Enter a positive integer: ", .text .globl main main: jal square square

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!