diff options
author | Santo Cariotti <dcariotti24@gmail.com> | 2020-04-02 15:00:21 +0200 |
---|---|---|
committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-04-02 15:00:21 +0200 |
commit | 4a839889b0b38b51c050c879d84f7f21aa57e934 (patch) | |
tree | 397341cef6a48bd1ff3ad0c0e63b90aab34630f3 /I_anno | |
parent | 2a45a9e3479bd57240866a672ea39f59a0a2dbc3 (diff) |
feat: find element into an array in asm
Diffstat (limited to 'I_anno')
-rw-r--r-- | I_anno/Architettura_Elaboratori/find_elem.asm | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/I_anno/Architettura_Elaboratori/find_elem.asm b/I_anno/Architettura_Elaboratori/find_elem.asm new file mode 100644 index 0000000..db7dc35 --- /dev/null +++ b/I_anno/Architettura_Elaboratori/find_elem.asm @@ -0,0 +1,34 @@ +array dcd 1, 3, 2, 4, 0 +arr_n dcd 5 +elem dcd 3 + + mov r0, #arr_n + ldr r1, [r0] ; r1 <- lunghezza array + + mov r0, #elem + ldr r2, [r0] ; r2 <- elemento da cercare + + mov r0, #array ; r0 <- puntatore al primo elemento dell'array + +loop + cmp r1, #0 + beq loop_end + + ldr r3, [r0] + + cmp r3, r2 + beq found + + add r0, r0, #4 + sub r1, r1, #1 + + + b loop + +found + mov r4, #0 ; r4 = 1, quindi trovato + end + +loop_end + mov r4, #1 ; r4 = 0, quindi non trovto + end |