00:01
Hello student here code is given to us but this code is in c language and we have to write this code into mips assembly language.
00:10
So here we have to translate the c code into the assembly language code and we have to use the minimum instruction and here there are two loop loop inner and outer loop there are two loop one is loop variable i and second loop variable is j in the c language.
00:28
Here a, b, i and j are the registers $s0, $s1, $t0 and $t1 all are the registers.
00:37
So here $s0 for a, $s1 for storing b, $t0 for storing i and $t1 storing for j.
00:45
So here assembly language code translate the given c code into mips assembly using a minimum number of the instructions.
00:53
So it uses a loop and arithmetic operation to iterate over the array and store the value in the memory.
00:59
So here first initialize i and j.
01:01
So here with the help of li load immediately.
01:05
So here $t0 register t0 is initialized with the zero value for i because t0 having the value i and t1 register having the value of j.
01:19
So these both register at the starting having the value zero at the starting time.
01:25
So here we are using the two loop outer and inner and outer loop having the loop variable i and for inner j variable.
01:34
So here outer loop variable.
01:36
So here check in the comment i have written if i is less than a because in the c language it is written for i equal to zero i less than a i plus plus.
01:53
So for this i am checking if i is less than a.
01:58
So this is written here.
02:00
Now after this done outer after this reset j here bge is used for the branching purpose branch if greater than this one.
02:16
So here branching for t1 and $1 is done for the inner loop after this calculate in the c language for two loop after this inside the two loop it's written i plus j.
02:34
So here i plus j calculate to calculate the i plus j first we execute the inner loop and first the outer loop now we check the inner loop for j equal to zero j less than b j plus plus.
02:54
So this is outer and this is inner.
02:57
So for outer loop branching is done and it is telling us then outer loop has been completed and here for branching is done branch if greater than or equal to for inner this is done.
03:20
So here now calculate i plus j because inside the loop i plus j is written that's why i plus j is written and its value is stored in tj...