Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

image text in transcribed

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. MS 1.ASTI" 1 # This program illustrates an exercise of determining whether an integer is a perfect square. 2 # The subroutine 'square' return 1 if the input is a perfect square or otherwise, using an appropriate return register 3 # The 'main' program should test the subroutine by first prompting the user for an integer to test, and then 4 # calling the subroutine with that integer as an argument. Determining on the outcome of the test, the 5 # 'main' program should generate an appropriate print statement. 6 # Feel free to add additional entries as you need them in the text or .data segments. 7 # Make sure that your 'main' program terminates gracefully. 8 # Be sure to comment your code. Use proper register conventions! .data 12 prompt: .asciiz "Enter a positive integer: " .text .globl main 18 main: jal square 22 square: Line: 22 Column: 8 Show Line Numbers 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. MS 1.ASTI" 1 # This program illustrates an exercise of determining whether an integer is a perfect square. 2 # The subroutine 'square' return 1 if the input is a perfect square or otherwise, using an appropriate return register 3 # The 'main' program should test the subroutine by first prompting the user for an integer to test, and then 4 # calling the subroutine with that integer as an argument. Determining on the outcome of the test, the 5 # 'main' program should generate an appropriate print statement. 6 # Feel free to add additional entries as you need them in the text or .data segments. 7 # Make sure that your 'main' program terminates gracefully. 8 # Be sure to comment your code. Use proper register conventions! .data 12 prompt: .asciiz "Enter a positive integer: " .text .globl main 18 main: jal square 22 square: Line: 22 Column: 8 Show Line Numbers

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

More Books

Students also viewed these Databases questions