-
Notifications
You must be signed in to change notification settings - Fork 0
/
cerinta2.asm
129 lines (101 loc) · 1.23 KB
/
cerinta2.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
.data
delim: .asciz " "
sir1: .space 100
cuv: .space 100
nr: .space 4
formatscanf: .asciz "%[^\n]"
f: .asciz "%d\n"
.text
.global main
main:
pushl $sir1
pushl $formatscanf
call scanf
popl %ebx
popl %ebx
pushl $delim
pushl $sir1
call strtok
popl %ebx
popl %ebx
movl %eax, cuv
pushl cuv
call atoi
popl %ebx
pushl %eax
etfor:
pushl $delim
pushl $0
call strtok
popl %ebx
popl %ebx
e1:
cmp $0, %eax
je exit
movl %eax, cuv
e2:
pushl cuv
call atoi
popl %ebx
movl %eax, nr
e3:
cmp $0, %eax
je verif
pushl %eax
jmp etfor
verif:
pushl cuv
call strlen
popl %ebx
cmp $1, %eax
jg operatie
pushl nr
jmp etfor
operatie:
xorl %ecx, %ecx
movl cuv, %edi
movb (%edi, %ecx, 1), %al
cmp $97, %al
je add
cmp $100, %al
je div
cmp $109, %al
je mul
cmp $115, %al
je sub
add:
popl %eax
popl %ebx
add %ebx, %eax
pushl %eax
jmp etfor
div:
xorl %edx, %edx
popl %ebx
popl %eax
divl %ebx
pushl %eax
jmp etfor
mul:
xorl %edx, %edx
popl %eax
popl %ebx
mull %ebx
pushl %eax
jmp etfor
sub:
popl %ebx
popl %eax
sub %ebx, %eax
pushl %eax
jmp etfor
exit:
popl %eax
pushl %eax
pushl $f
call printf
popl %ebx
popl %ebx
movl $1, %eax
xorl %ebx, %ebx
int $0x80