-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstuff.s
More file actions
49 lines (28 loc) · 776 Bytes
/
stuff.s
File metadata and controls
49 lines (28 loc) · 776 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
.global _main
_main:
MOV R0, #12@ is the dividend
MOV R1, #0@ is the quotient
MOV R2, #5@ is the divisor
MOV R3, #0@ check if r0 is r3
MOV R7, #5 @number of loops
LOOP:
SUB R0, R0, R2@ r = r-x
CMP R0, R3@ if r0 greater than or equal to r3
BGE RES1@ jump to res1 is r0 >= r3
b RES2@ jump to res2 if r0 < r3
RES1:@ if r >= 0
MOV R1, R1, LSL #1@shift r1,
MOV R2, R2, LSR #1@shift r2 right
SUB R7, R7, #1@ subtract 1 from loop
CMP R7, R3@ compare if r7 >= r3
BGT LOOP@ jump if value meet
b EXIT
RES2:
ADD R0, R0, R2@ r = r + x
MOV R1, R1, LSL #1@shift r0 left
MOV R2, R2, LSR #1@ shift r2 right
SUB R7, R7, #1@subtract 1 from loop
CMP R7, R3@ compare if r7 >= r3
BGT LOOP@ jump if value meet
b EXIT
EXIT: