nihonium
/
mipt_clang
Archived
1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

69 lines
734 B
NASM

3 years ago
global main
extern printf
extern scanf
extern qsort
section .text
main:
push n
push readn
call scanf
3 years ago
add esp, 8
3 years ago
xor ebx, ebx
loop1:
3 years ago
cmp ebx, dword [n]
3 years ago
je nya1
3 years ago
lea eax, [x + 4 * ebx]
push eax
3 years ago
push nya
call scanf
3 years ago
add esp, 8
3 years ago
3 years ago
inc ebx
jmp loop1
3 years ago
nya1:
push compare
3 years ago
push dword 4
3 years ago
push dword [n]
push x
call qsort
add esp, 16
3 years ago
xor ebx, ebx
loop2:
cmp ebx, dword [n]
je nya2
lea eax, [x + 4 * ebx]
3 years ago
3 years ago
push dword [eax]
push write
call printf
add esp, 8
inc ebx
jmp loop2
nya2:
3 years ago
xor eax, eax
ret
compare:
3 years ago
mov eax, [esp+4]
mov eax, dword [eax]
mov ebx, [esp + 8]
mov ebx, dword [ebx]
sub eax, ebx
3 years ago
ret
section .data
3 years ago
write db "%d ", 0
nya db "%d", 0
3 years ago
readn db "%d", 0
3 years ago
3 years ago
section .bss
n resd 1
3 years ago
x resd 10000