Question: write a function in mips draw _ spiral ( int x , int y , int size, int colour ) that draws a spiral starting

write a function in mips draw_spiral(int x, int y, int size, int colour) that draws a spiral starting at (x, y) where the first branch of the spiral has length size. Use functions draw_horizontal_line and draw_vertical_line to draw the spiral. Modify your main program to call draw_spiral.
Note: Feel free to come up with your own implementation of drawing a spiral. But here is a possible implementation for reference:
draw_spiral(int x, int y, int size, int color){
while(size>1){
draw_horizontal_line(x, y, size, color);
x = x + size -1;
size--;
draw_vertical_line(x, y, size, color);
y = y + size -1;
size--;
x = x - size +1;
draw_horizontal_line(x, y, size, color);
size--;
y = y - size +1;
draw_vertical_line(x, y, size, color);
size--;
}
}
Hint: Print different colours for vertical and horizontal lines while debugging.
Example: For the user input:
Please enter the x coordinate of the position:
1--- this is the input
Please enter the y coordinate of the position:
1--- this is the input
Please enter the size:
29--- this is the input
Please enter the colour (w-white, g-green, y-yellow and r-red):
w --- this is the input
The result of draw_spiral(1,1,29,w) should be:
Example of spiral
 write a function in mips draw_spiral(int x, int y, int size,

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!