Write the ARM program code for factorial by using iteration and DO NOT use recursion.
This is the model of the recursion one:
fact: SUB sp, sp, #8 ; adjust sp for lr & r0
STR lr, [sp, #4] ; push lr onto stack
STR r0, [sp, #0] ; push r0 onto stack
CMP r0, #1 ; Compare r0 (= n) to 1
BGEL1: if n >= 1 goto L1
MOV r0, #1 ; if n < 1, r0 = 1 (base case)
ADD sp, sp, #8 ; pop lr & r0 off stack
MOV pc, lr ; return to the caller
L1: SUB r0, r0, #1 ; if (n >= l) n = n-1
BL fact ; call fact with (n-1)
MOV r12, r0 ; save the return result from BL to r12
LDR r0, [sp, #0] ; restore argument n from stack
LDR lr, [sp, #4] ; restore return address from stack
ADD sp, sp, #8 ; update sp pointer to pop 2 registers
MUL r0, r12, r0 ; compute n * fact(n-1)
MOV pc, lr ; return to the caller