;The semicolon is used to lead an inline documentation
;When you write your program, you could have your info at the top document block
;For Example: Your Name, Student Number, what the program is for, and what it does 

;
; See if you can figure out what this program does
;
;;; Directives
	PRESERVE8
	THUMB 
; Vector Table Mapped to Address 0 at Reset
; Linker requires __Vectors to be exported
	AREA RESET, DATA, READONLY
	EXPORT __Vectors
__Vectors 
	DCD 0x20001000 ; stack pointer value when stack is empty
	DCD Reset_Handler ; reset vector
 
	ALIGN
 
;Your Data section
;AREA DATA
; AREA MYRAM, DATA, READWRITE

	


N DCD 3


;Your Data section
;AREA DATA
;	AREA MYRAM, DATA, READWRITE


; The program
; Linker requires Reset_Handler
	AREA MYCODE, CODE, READONLY
	 ENTRY
	 EXPORT Reset_Handler
Reset_Handler
;;;;;;;;;;User Code Start from the next line;;;;;;;;;;;;
	
	LDR R9, =N
	LDR R3, [R9]
	MOV R5, #1
	MOV R7, R3 ; COUNT
LOOP
	
	cmp R3, #0
	BNE FAC
	
	B STOP
	
	
FAC
	MUL R3, R3,R7
	SUB R7,R7,#1
	B LOOP


STOP
	B STOP
	END 