diff options
author | Santo Cariotti <santo@dcariotti.me> | 2021-02-06 19:56:36 +0100 |
---|---|---|
committer | Santo Cariotti <santo@dcariotti.me> | 2021-02-06 19:56:36 +0100 |
commit | d2edbc38cac8da52f58c5cd3da6c0c625fa05736 (patch) | |
tree | a51e9a4e56fc9d4c7c9e37576dceedca3a0c72b4 /Year_1/Computer_Architecture/odd_even_numbers.asm | |
parent | 98f34040820dc3a964b7be59a698323e8cc6c8a3 (diff) |
conf: rename
Diffstat (limited to 'Year_1/Computer_Architecture/odd_even_numbers.asm')
-rw-r--r-- | Year_1/Computer_Architecture/odd_even_numbers.asm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Year_1/Computer_Architecture/odd_even_numbers.asm b/Year_1/Computer_Architecture/odd_even_numbers.asm new file mode 100644 index 0000000..996fd62 --- /dev/null +++ b/Year_1/Computer_Architecture/odd_even_numbers.asm @@ -0,0 +1,36 @@ +arr_n dcd 8 +array dcd 1, 2, 4, 6, -5, 8, 7, 3 +s_arr dcd 0 + + mov r0, #arr_n + ldr r0, [r0] + mov r1, r0 + + mov r4, #1 ; 0 = even, 1 = odd + mov r6, #0 ; number of elements on new sequence + + mov r2, #s_arr + + mov r1, #array + +loop + cmp r0, #0 + beq end_program + ldr r3, [r1], #4 + mov r5, r3 + + and r5, r3, #1 + cmp r5, r4 ; check if element stored in r3 is odd or even + beq data_store +subn_loop + sub r0, r0, #1 + b loop + +data_store + str r3, [r2], #4 + add r6, r6, #1 + b subn_loop + +end_program + str r6, [r2] + end |