You are on page 1of 1

;FACTORIAL USING RECURSION

AREA RESET,DATA,READONLY
EXPORT __Vectors

__Vectors
DCD 0x10001000
DCD Reset_Handler
ALIGN

AREA mycode,CODE,READONLY
ENTRY
EXPORT Reset_Handler
Reset_Handler

LDR R1,=NUM
LDR R0,[R1]
BL FACT
LDR R5,=FACTO
STR R2,[R5]
STOP
B STOP

FACT
CMP R0,#1
BEQ EXIT
PUSH {R0,R14}
SUB R0,#1
BL FACT
POP {R0,R14}
MUL R2,R0,R2
BX LR
EXIT
MOV R2,#1
BX LR

NUM DCD 5
AREA mydata,DATA,READWRITE
FACTO DCD 0
END

You might also like