; find all divisors of a number like 6, and store in data memory. find if number is perfect or not. if sum of divisors is the number itself, then perfect. if perfect, store FF next to divisor list, otherwise store 11 AREA RESET, DATA, READONLY EXPORT __Vectors __Vectors DCD 0x10001000 DCD Reset_Handler ALIGN AREA MYCODE, CODE, READONLY ENTRY EXPORT Reset_Handler Reset_Handler LDR R0, =10 ; value MOV R1, #0 ; counter LDR R12, =0x10001000 ; address MOV R2, #1 ; factoriser MOV R4, R0 LSRS R4, R4, #1 LOOP_I ; loop CMP R2, R4 BHI DONE_LOOP MOV R3, R0 DIV_LOOP ; division CMP R3, R2 BLT CHECK_REM SUB R3, R3, R2 B DIV_LOOP CHECK_REM ; checks if factor CMP R3, #0 BNE NEXT_I ADD R1, R1, R2 STR R2, [R12] ADD R12, R12, #4 NEXT_I ; iterator ADD R2, R2, #1 B LOOP_I DONE_LOOP ; checker for perfect CMP R1, R0 BNE NOT_PERF MOV R5, #0xFF B STORE_FLAG NOT_PERF MOV R5, #0x11 STORE_FLAG ; store STR R5, [R12] STOP B STOP END