-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperate.S
66 lines (56 loc) · 1.34 KB
/
operate.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
66
.data
.balign 4
enterFirst: .asciz "Enter the first number: "
.balign 4
enterSecond: .asciz "Enter the second number: "
.balign 4
inputFormat: .asciz "%f"
.balign 4
addition: .asciz "The result of adding is: %f\n"
.balign 4
subtraction: .asciz "The result of subtracting is: %f\n"
.balign 4
multiply: .asciz "The result of multiplying is: %f\n"
.balign 4
division: .asciz "The result of diviving is: %f\n"
.text
.global main
.global printf
.global scanf
main:
PUSH {R0, LR}
LDR R0, =enterFirst
BL printf
SUB SP, SP, #8
LDR R0, =inputFormat
MOV R1, SP
BL scanf
VLDR S1, [SP]
VCVT.F64.F32 D1, S1
LDR R0, =enterSecond
BL printf
SUB SP, SP, #8
LDR R0, =inputFormat
MOV R1, SP
BL scanf
VLDR S2, [SP]
VCVT.F64.F32 D2, S2
VADD.F64 D0, D1, D2
VMOV R2, R3, D0
LDR R0, =addition
BL printf
VSUB.F64 D0, D1, D2
VMOV R2, R3, D0
LDR R0, =subtraction
BL printf
VMUL.F64 D0, D1, D2
VMOV R2, R3, D0
LDR R0, =multiply
BL printf
VDIV.F64 D0, D1, D2
VMOV R2, R3, D0
LDR R0, =division
BL printf
ADD SP, SP, #16
POP {R0, LR}
BX LR