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.
62 lines
877 B
NASM
62 lines
877 B
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 "%lld",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 esi, esi
|
|
xor edi, edi
|
|
xor ebx, ebx
|
|
loop2@start:
|
|
cmp ebx, ecx
|
|
je loop2@end
|
|
mov eax, dword ptr a[ebx*4]
|
|
cdq
|
|
add eax, esi
|
|
adc edx, edi
|
|
mov esi, eax
|
|
mov edi, edx
|
|
inc ebx
|
|
jmp loop2@start
|
|
loop2@end:
|
|
push edi
|
|
push esi
|
|
push offset strPrintfFmt
|
|
call _printf
|
|
add esp, 12
|
|
push 0
|
|
call ExitProcess
|
|
_main endp
|
|
end _main |