R1 = 100 //base memory address of array1 R2 = 200 //base memory address of array2 R3 = 300 //base memory address of array3 R4 = 400 //base memory address of array4 R5 = 500 //base memory address of array5 R6 = 600 //base memory address of array6 R7 = 700 //base memory address of array7 R8 = 800 //base memory address of array8 R9 = 5 //init value for loop counter R10 = 5 //loop counter R11 = 2 // first if condition R12 = 2 // second if condition R13 = 0 // temporary R21 = 1 //compute the factorial of R1 M[100] = 2 M[101] = 3 M[102] = 4 M[103] = 5 M[104] = 6 M[105] = 7 M[200] = 8 M[201] = 7 M[202] = 6 M[203] = 5 M[204] = 4 M[205] = 3 M[500] = 9 M[501] = 8 M[502] = 7 M[503] = 6 M[504] = 5 M[505] = 4 M[600] = 11 M[601] = 12 M[602] = 13 M[603] = 14 M[604] = 15 M[605] = 16 ## Branch1: SUBI R11 R11 #1 //decrease R11 BRNZ R11 Branch2 ADD R1 R5 R0 //init R1 with R5 ADD R2 R6 R0 //init R1 with R6 ADD R3 R7 R0 //init R1 with R7 ADD R4 R8 R0 //init R1 with R8 Loop1: LD R25 R1 //load the value of the element of first array LD R26 R2 //load the value of the element of second array ADD R20 R25 R26 //add the 2 values and put the result in R20 ST R20 R3 //store the result in element of third array ADD R31 R25 R0 //init R31 with R25 Loop2: MUL R21 R21 R31 //multiply R21 and R31 SUBI R31 R31 #1 // decrease R31 BRNZ R31 Loop2 //continue iteration if the loop counter != 0 ST R21 R4 ADDI R21 R0 #1 // init R21 ADDI R1 R1 #1 //increment the address of first array ADDI R2 R2 #1 //increment the address of second array ADDI R3 R3 #1 //increment the address of third array ADDI R4 R4 #1 //increment the address of fourth array SUBI R10 R10 #1 //decrement the loop counter BRNZ R10 Loop1 //continue iteration if the loop counter != 0 ADD R10 R9 R0 // initialize R10 with R9 Branch2: SUBI R12 R12 #1 //decrease R12 BRNZ R12 Loop1 ADDI R12 R12 #1 //one more time run BRNZ R11 Branch1 ADDI R21 R21 #1 //final result +1 ST R21 R4 ## R0-31 M[100-110] M[200-210] M[300-310] M[400-410] M[500-510] M[600-610] M[700-710] M[800-810]