-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.s
executable file
·65 lines (54 loc) · 1.13 KB
/
test.s
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
area code, readonly
entry
start
adr r13,stack
mov r1,#x
mov r0,#n
str r1,[r13,#-4]!
str r0,[r13,#-4]!
sub r13,r13,#4
bl power
ldr r0,[r13],#4
add r13,r13,#8
adr r11,result
str r0,[r11]
loop b loop
;power function
power stmfd r13!,{r0,r1,fp,lr}
mov fp,r13
ldr r1,[fp,#0x18]
ldr r0,[fp,#0x14]
cmp r0,#0
moveq r0,#1
streq r0,[fp,#0x10]
beq return
and r0,#1
cmp r0,#1
ldr r0,[fp]
bne else
sub r0,#1
str r0,[r13]
sub r13,r13,#4
bl power
ldr r0,[r13],#4
add r13,r13,#8
mul r0,r1,r0
str r0,[fp,#0x10]
b return
else mov r0,r0,lsr #1
str r0,[r13]
sub r13,r13,#4
bl power
ldr r0,[r13],#4
add r13,r13,#8
mul r1,r0,r0
str r1,[fp,#0x10]
return mov r13,fp
ldmfd r13!,{r0,r1,fp,pc}
area xtothen, data, readwrite
n equ 4
x equ 3
result dcd 0
space 200
stack dcd 0
end