global main extern printf extern scanf extern qsort section .text main: ; read N push n push readn call scanf add esp ,8 ; read loop for x xor ebx, ebx loop1: cmp bx, word [n] je nya1 lea eax, [x + 2 * ebx] dbg1: push eax push nya call scanf add esp, 8 dbg2: inc ebx jmp loop1 nya1: push compare push dword 2 push dword [n] push x ;push x ;push dword [n] ;push dword 2 ; size of element ;push compare call qsort add esp, 16 xor eax, eax ret compare: ;mov ebp, esp ;sub esp, 16 ;pop eax ;pop ebx ;push ebp ;mov ebp, esp mov eax, dword [esp + 4] ;lea ebx, [ebp - 2] ;mov ebx, [esp + 8] sub eax, [esp + 8] ret section .data nya db "%hu", 0 readn db "%d", 0 section .bss n resd 1 x resw 10000