-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd1.s
More file actions
32 lines (28 loc) · 724 Bytes
/
Copy pathadd1.s
File metadata and controls
32 lines (28 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
.global _start
main:
_start:
mov r6, #5 @ number to go up to
mov r1, #0 @ initial value
mov r2, #1 @ counter
_loop:
add r1, r1, r2
b _write @print the value
_write:
push {r1, r2, r6, lr}
add r3, r1, #48
ldr r0, =character
str r3, [r0]
mov r7,#4 @ syscall for output
mov r0,#1 @ output stream for R1
ldr r1, =character
mov r2,#1
swi 0
pop {r1, r2, r6, lr}
cmp r1,r6 @ compare if the value is equal to 'n'
bne _loop @ if less than, then add again and print
end:
mov R7,#1 @ syscall for exit
swi 0
.data
character:
.word 0