-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodulo.s
More file actions
26 lines (20 loc) · 773 Bytes
/
modulo.s
File metadata and controls
26 lines (20 loc) · 773 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
@ modulo.s
@ This function takes as input the number that is having modulo performed on it and
@ the number to take the modulo by. It computes the modulo of these two numbers and
@ returns it to the calling function.
.cpu cortex-a53
.fpu neon-fp-armv8
.data
.text
.align 2
.global modulo
.syntax unified
.type modulo, %function
modulo:
push {fp, lr} @ Pushes fp and lr onto the stack
add fp, sp, #4 @ Moves up one memory location from sp and stores it in fp
udiv r2, r0, r1 @ Divides r0 by r1 and stores it in r2
mul r2, r1, r2 @ Multiplies r2 by r1 and stores it in r2
sub r0, r0, r2 @ Subtracts r2 from r0 and stores it in r0
sub sp, fp, #4 @ Moves down one memory location from fp and stores it in sp
pop {fp, pc} @ Pops fp and pc from the stack