Lab Tasks In Lab 6, you modified the for-loop macro presented in the above tutorial to include an interval. If you missed lab 6 or forgot about that, here is what you needed to do there: Lab 6 starts here: The for loop in the above tutorial prints a range of consecutive numbers. Copy the code from the tutorial to Mars and make it execute. The macro call: for ($t0, 1, 10, body) will lead to printing numbers from 1 to 10, one each in a new line. Your task is to modify the code to pass another argument (an interval) to the macro so that the numbers are printed with the given interval in the same line where a space separates the numbers. Your program will also print a string (“Here is the output: ”) before the series of numbers using the print_str macro. For example, Macro call: for ($t0, 1, 20, 3, body) will produce the following output: Here is the output: 1 4 7 10 13 16 19 Lab 6 ends here. Now, in this lab (Lab 7), you will make further modification to the same macro to make the for-loop more versatile. In addition to passing an interval, your macro call will be able to pass a character (‘i’ or ‘d’) indicating if you want to increment or decrement the value of the iterator. In the case of increment, the value of the to argument will be greater than the value of the from argument. Conversely, in the case of decrement, the value for the to argument will be less than the value of the from argument. Examples of macro calls and the output: Call: for ($t0, 1, 20, 'i', 3, body) Output: 1 4 7 10 13 16 19 Call: for ($t0, 20, 1, 'd', 3, body) Output: 20 17 14 11 8 5 2 Hints: In the macro, you may need to load 'i' and 'd' to two registers before comparing it to the increment/decrement type argument-register. You can use li instruction for this purpose. Based on the comparison results, your code will branch to two different labels where the iterator register will either be incremented or decremented. Loop termination conditions need to be appropriately set. Submission Instructions Submit the complete program (.asm file), and screenshots of the execution of the program that show the output for the following two macro calls: for ($t0, 15, 450, 'i', 5, body) for ($t0, 100, 0, 'd', 10, body)
Introduction to Macros in Mars
Read about macros here:
https://courses.missouristate.edu/kenvollmar/mars/help/MacrosHelp.html
Lab Tasks
In Lab 6, you modified the for-loop macro presented in the above tutorial to include an interval. If you missed lab 6 or forgot about that, here is what you needed to do there:
Lab 6 starts here:
The for loop in the above tutorial prints a range of consecutive numbers. Copy the code from the tutorial to Mars and make it execute. The macro call: for ($t0, 1, 10, body) will lead to printing numbers from 1 to 10, one each in a new line. Your task is to modify the code to pass another argument (an interval) to the macro so that the numbers are printed with the given interval in the same line where a space separates the numbers. Your
Macro call: for ($t0, 1, 20, 3, body) will produce the following output:
Here is the output: 1 4 7 10 13 16 19
Lab 6 ends here.
Now, in this lab (Lab 7), you will make further modification to the same macro to make the for-loop more versatile. In addition to passing an interval, your macro call will be able to pass a character (‘i’ or ‘d’) indicating if you want to increment or decrement the value of the iterator. In the case of increment, the value of the to argument will be greater than the value of the from argument. Conversely, in the case of decrement, the value for the to argument will be less than the value of the from argument. Examples of macro calls and the output:
Call: for ($t0, 1, 20, 'i', 3, body)
Output: 1 4 7 10 13 16 19
Call: for ($t0, 20, 1, 'd', 3, body)
Output: 20 17 14 11 8 5 2
Hints: In the macro, you may need to load 'i' and 'd' to two registers before comparing it to the increment/decrement type argument-register. You can use li instruction for this purpose. Based on the comparison results, your code will branch to two different labels where the iterator register will either be incremented or decremented. Loop termination conditions need to be appropriately set.
Submission Instructions
Submit the complete program (.asm file), and screenshots of the execution of the program that show the output for the following two macro calls:
for ($t0, 15, 450, 'i', 5, body)
for ($t0, 100, 0, 'd', 10, body)
Step by step
Solved in 3 steps
sorry but the code compiled with errors and not outputing anything