cource work

  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
179
180
181
182
183
184
185
186
187
188
189
.section .rodata
.align 8
.LC0:
.string "Hello. This's my final work program "
.LC1:
.string "You can chose next function: "
.LC2:
.string "1. Type text "
.LC3:
.string "2. View content file "
.LC4:
.string "3. About use "
.LC5:
.string "4. Exit "
.LC6:
.string "\nPlease write number: "
.LC7:
.string "%d"
.LC8:
.string "You can write you chars: "
.LC9:
.string "a"
.LC10:
.string "text.txt"
.align 8
.LC11:
.string "You press %c. ASCII code : %d \n"
.LC12:
.string "===End you text===\n"
.LC13:
.string "Data in file: \n"
.LC14:
.string "r"
.LC15:
.string "\n\n!!! FILE NOT FOUND !!!\n"
.LC16:
.string "%s"
.LC17:
.string "\n\n===EOF===\n"
.align 8
.LC18:
.string "Hello. This's my final cource program \nYou can:\n1.Type and save text\n2.View text\nThis program very simple, because writing in Assembler AT&T for training =)"
.LC19:
.string "Good luck! "
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
pushq %rbx
subq $312, %rsp
.cfi_offset 3, -24
movq %fs:40, %rax
movq %rax, -24(%rbp)
xorl %eax, %eax
.L2:
movl $.LC0, %edi
call puts
movl $.LC1, %edi
call puts
movl $.LC2, %edi
call puts
movl $.LC3, %edi
call puts
movl $.LC4, %edi
call puts
movl $.LC5, %edi
call puts
movl $.LC6, %edi
movl $0, %eax
call printf
leaq -312(%rbp), %rax
movq %rax, %rsi
movl $.LC7, %edi
movl $0, %eax
call __isoc99_scanf
movl -312(%rbp), %eax
movl %eax, -312(%rbp)
movl -312(%rbp), %eax
cmpl $2, %eax
je .L4
cmpl $2, %eax
jg .L5
cmpl $1, %eax
je .L6
jmp .L3
.L5:
cmpl $3, %eax
je .L7
cmpl $4, %eax
je .L8
jmp .L3
.L6:
movl $.LC8, %edi
movl $0, %eax
call printf
movl $.LC9, %esi
movl $.LC10, %edi
call fopen
movq %rax, -304(%rbp)
.L9:
call getchar
movl %eax, -308(%rbp)
movl -308(%rbp), %ecx
movl -308(%rbp), %edx
movq -304(%rbp), %rax
movl $.LC11, %esi
movq %rax, %rdi
movl $0, %eax
call fprintf
cmpl $27, -308(%rbp)
jne .L9
movl $.LC12, %edi
call puts
movq -304(%rbp), %rax
movq %rax, %rdi
call fclose
jmp .L2
.L4:
movl $.LC13, %edi
call puts
movl $.LC14, %esi
movl $.LC10, %edi
call fopen
movq %rax, -296(%rbp)
cmpq $0, -296(%rbp)
jne .L10
movl $.LC15, %edi
call puts
jmp .L2
.L10:
jmp .L12
.L13:
leaq -288(%rbp), %rax
movq %rax, %rsi
movl $.LC16, %edi
movl $0, %eax
call printf
.L12:
leaq -288(%rbp), %rdx
movq -296(%rbp), %rax
movl $.LC16, %esi
movq %rax, %rdi
movl $0, %eax
call __isoc99_fscanf
cmpl $-1, %eax
jne .L13
movl $.LC17, %edi
call puts
movq -296(%rbp), %rax
movq %rax, %rdi
call fclose
nop
jmp .L2
.L7:
movl $.LC18, %edi
call puts
nop
movl $0, %eax
jmp .L16
.L8:
movl $.LC19, %edi
call puts
movl $0, %eax
jmp .L16
.L3:
movl $0, %eax
.L16:
movq -24(%rbp), %rbx
xorq %fs:40, %rbx
je .L17
call __stack_chk_fail
.L17:
addq $312, %rsp
popq %rbx
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.8.1-10ubuntu9) 4.8.1"
.section .note.GNU-stack,"",@progbits