Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern fprintf
- extern fscanf
- extern fopen
- extern qsort
- extern scanf
- extern fclose
- section .bss
- a resd 0xACE
- section .data
- num dd 0
- scanner db `%d`, 0
- section .rodata
- iomode db `%d`, 0
- output_mode db `%d `, 0
- input_name db "input.txt", 0
- output_name db `output.txt`, 0
- fileInputMode db `r`, 0
- fileOutputMode db `w+`, 0
- section .text
- global main
- main:
- mov ebp, esp
- and esp, 0xfffffff0
- sub esp, 8
- push fileInputMode
- push input_name
- call fopen
- add esp, 12
- push num
- push iomode
- push eax
- mov edi, 0
- .input_while:
- call fscanf
- cmp eax, 0
- jle .stop_input_while
- mov esi, [num]
- mov [a + 4 * edi], esi
- inc edi
- jmp .input_while
- .stop_input_while:
- call fclose
- add esp, 16
- push comporator ; �������� �������� - ����������
- push 4 ; ������ �������� - ������ �������� �������
- push edi ; ������ �������� - ������ �������
- push a ; ������ �������� - ��������� �� ������ �������
- call qsort
- add esp, 8
- push fileOutputMode
- push output_name
- call fopen
- add esp, 12
- push 123 ; ������ �������� - ��� �������
- push output_mode ; ������ �������� - ����� �����
- push eax ; ������ �������� - ��������� �� ����
- mov esi, 0
- .print_for:
- cmp esi, edi
- jz .stop_print_for
- mov ebx, [a + 4 * esi]
- mov dword [esp + 8], ebx
- call fprintf
- inc esi
- jmp .print_for
- .stop_print_for:
- mov esp, ebp
- xor eax, eax
- ret
- global comporator
- comporator:
- .prolog:
- push ebp
- mov ebp, esp
- push ebx
- ;push edi
- ;push esi
- mov eax, dword [ebp + 8] ; ���������� ������� ���������
- mov ebx, dword [ebp + 12] ; ���������� ������� ���������
- mov eax, [eax] ; omg
- mov ebx, [ebx]
- .end_of_prolog:
- cmp eax, ebx
- jz .equal
- cmp eax, ebx
- jl .minus
- mov eax, 1
- jmp .epilog
- .minus:
- mov eax, -1
- jmp .epilog
- .equal:
- mov eax, 0
- jmp .epilog
- .epilog:
- ;pop esi
- ;pop edi
- pop ebx
- mov esp, ebp
- pop ebp
- ret
- .end_of_epilog:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement