Archived
1
0
Fork 0
This repository has been archived on 2022-06-20. You can view files and clone it, but cannot push or open issues or pull requests.
mipt_clang/nasm/J.asm
2022-04-08 12:15:53 +03:00

68 lines
734 B
NASM

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