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.

86 lines
1.1 KiB
NASM

.686p
.model flat
include kernel32.inc
includelib kernel32.lib
includelib msvcrt.lib
extern _printf:proc
extern _scanf:proc
extern _strlen:proc
_BSS SEGMENT
a dd 100000 dup(?)
_BSS ENDS
.data
strScanfFmt db "%d",0
strPrintfFmt db "%d ",0
.code
_main proc
n=-4
sub esp, 4
lea edx, dword ptr n[ebp]
push edx
push offset strScanfFmt
call _scanf
add esp, 8
mov ecx, dword ptr n[ebp]
xor ebx, ebx
loop1@start:
cmp ebx, ecx
je loop1@end
push ecx
lea edx, dword ptr a[ebx*4]
push edx
push offset strScanfFmt
call _scanf
add esp, 8
pop ecx
inc ebx
jmp loop1@start
loop1@end:
xor ebx, ebx
loop2@start:
cmp ebx, ecx
je loop2@end
mov esi, ebx
mov edi, esi
loop2_1@start:
cmp edi, ecx
je loop2_1@end
mov edx, dword ptr a[edi*4]
cmp edx, dword ptr a[esi*4]
cmovl esi, edi
inc edi
jmp loop2_1@start
loop2_1@end:
mov edx, dword ptr a[ebx*4]
mov edi, dword ptr a[esi*4]
mov dword ptr a[ebx*4], edi
mov dword ptr a[esi*4], edx
inc ebx
jmp loop2@start
loop2@end:
xor ebx, ebx
loop3@start:
cmp ebx, ecx
je loop3@end
push ecx
push dword ptr a[ebx*4]
push offset strPrintfFmt
call _printf
add esp, 8
pop ecx
inc ebx
jmp loop3@start
loop3@end:
push 0
call ExitProcess
_main endp
end _main