-
Notifications
You must be signed in to change notification settings - Fork 0
/
testUDlong.asm
179 lines (146 loc) · 2.73 KB
/
testUDlong.asm
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
SECTION .data
BIGINTEGERLEN EQU 16
WELCOME: db "You can insert the following chars: [0-9a-fA-F]. All others are set to 0.",10,0
ENTER: db "Enter %c:",10,0
CALCOUTPUT: db "%c %c %c =",10,0
VARIS: db "%c is: ",10,0
SECTION .bss
X resb BIGINTEGERLEN
Y resb BIGINTEGERLEN
Z resb BIGINTEGERLEN
R resb BIGINTEGERLEN
S resb BIGINTEGERLEN
T resb BIGINTEGERLEN
SECTION .text
EXTERN addition, subtraction, multiplication, readUDlong, writeUDlong, copyUDlong
EXTERN printf
GLOBAL main
main:
nop
mov rdi, WELCOME
xor rax, rax
call printf
mov rdi, ENTER
mov rsi, 'X'
xor rax, rax
call printf
mov rdi, X
call readUDlong
mov rdi, ENTER
mov rsi, 'Y'
xor rax, rax
call printf
mov rdi, Y
call readUDlong
mov rdi, ENTER
mov rsi, 'Z'
xor rax, rax
call printf
mov rdi, Z
call readUDlong
mov rdi, X
mov rsi, R
call copyUDlong
mov rdi, Y
mov rsi, S
call copyUDlong
mov rdi, Z
mov rsi, T
call copyUDlong
mov rdi, X
mov rsi, Y
call addition
mov rdi, CALCOUTPUT
mov rsi, 'X'
mov rdx, '+'
mov rcx, 'Y'
xor rax, rax
call printf
mov rdi, X
call writeUDlong
mov rdi, VARIS
mov rsi, 'X'
xor rax, rax
call printf
mov rdi, X
call writeUDlong
mov rdi, VARIS
mov rsi, 'Y'
xor rax, rax
call printf
mov rdi, Y
call writeUDlong
mov rdi, X
mov rsi, Y
call subtraction
mov rdi, CALCOUTPUT
mov rsi, 'X'
mov rdx, '-'
mov rcx, 'Y'
xor rax, rax
call printf
mov rdi, X
call writeUDlong
mov rdi, VARIS
mov rsi, 'X'
xor rax, rax
call printf
mov rdi, X
call writeUDlong
mov rdi, VARIS
mov rsi, 'Y'
xor rax, rax
call printf
mov rdi, Y
call writeUDlong
mov rdi, R
mov rsi, S
call subtraction
mov rdi, CALCOUTPUT
mov rsi, 'R'
mov rdx, '-'
mov rcx, 'S'
xor rax, rax
call printf
mov rdi, R
call writeUDlong
mov rdi, VARIS
mov rsi, 'R'
xor rax, rax
call printf
mov rdi, R
call writeUDlong
mov rdi, VARIS
mov rsi, 'S'
xor rax, rax
call printf
mov rdi, S
call writeUDlong
mov rdi, T
mov rsi, Z
call multiplication
mov rdi, CALCOUTPUT
mov rsi, 'T'
mov rdx, '*'
mov rcx, 'Z'
xor rax, rax
call printf
mov rdi, T
call writeUDlong
mov rdi, VARIS
mov rsi, 'T'
xor rax, rax
call printf
mov rdi, T
call writeUDlong
mov rdi, VARIS
mov rsi, 'Z'
xor rax, rax
call printf
mov rdi, Z
call writeUDlong
call exit
exit:
mov rax, 60
mov rdi, 0
syscall