;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 12
NUM1 DCD 3, -7, 2, -2, 10, 20, 30, 15, 32, 8, 64, 66


;Your Data section
;AREA DATA
	AREA MYRAM, DATA, READWRITE

even
	SPACE 100
odd
	SPACE 100


; 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 R10, =even
	LDR R11, =odd
	LDR R0, [R9]
	MOV R3, #0
	
	LDR R1, =NUM1
	
LOOP
	
	LDR R2, [R1], #4
	
	AND R8, R2, #0x00000001 ; check
	CMP R8, #0x00000000
	
	BNE SKIP_FOR_ODD
	STR R2, [R10], #4 ; STORE EVEN
	B SKIP
	
	
SKIP_FOR_ODD	
	
	STR R2, [R11], #4 ; STORE ODD
SKIP
	SUB R0, R0, #1
	CMP R0, #0
	BNE LOOP
	



STOP
	B STOP
	END 