Q1 Run what s downloadable from Programming Project 1 on eLearning in MARS examine the corresponding registers in the MARS windows and look in the code of what s and try to work out what it does Check whether the program works if the argument is changed to 6 1 0 10 20 etc Answer what the program does in one Sentence Ans This MIPS program calculates the product of a given argument stored in arg and the number itself essentially performing the following operation result arg arg Here s how the program works step by step 1 Load the argument 2 Initialize variables Initially argument 5 was stored in the memory as a word under the label arg Then we load arg 5 in register t1 and s1 Then we initialize s3 to zero using the add function where we will store the result Program check if t1 is 0 If t1 is zero then the program skips to the end since multiplying by zero would give a result of zero 3 Loop multiplying the argument by itself The loop fori adds the values in s1 to s3 and negate t1 by 1 until t1 is zero 4 End the program When the loop is done the program calls syscall to terminate Behavior with Different Arguments If the argument in arg is changed to 6 the program will compute 6 6 36 With 1 it computes 1 1 1 With 0 the program will exit early without any loop since 0 0 0 For 10 it computes 10 10 100 For 20 it computes 20 20 400 Answer in one sentence The program calculates the square of the given argument stored in memory arg
View Full Document