diff --git a/.gitignore b/.gitignore index 3a2a3c0..197d31e 100644 --- a/.gitignore +++ b/.gitignore @@ -497,3 +497,4 @@ fabric.properties # Android studio 3.1+ serialized cache file .idea/caches/build_file_checksums.ser +*.lnk \ No newline at end of file diff --git a/1.1.asm b/1.1.asm new file mode 100644 index 0000000..9079c5c --- /dev/null +++ b/1.1.asm @@ -0,0 +1,40 @@ +.686p +.model flat +include kernel32.inc +includelib kernel32.lib +includelib msvcrt.lib +extern _printf:proc +extern _scanf:proc +extern _strlen:proc +.data +strScanfFmt db "%d%d%d",0 +strPrintfFmt db "%d",0 +.code +_main proc +var1=-4 +var2=-8 +var3=-12 +mov ebp, esp +sub esp, 12 +lea edx, dword ptr [ebp+var3] +push edx +lea edx, dword ptr [ebp+var2] +push edx +lea edx, dword ptr [ebp+var1] +push edx +push offset strScanfFmt +call _scanf +add esp, 16 +imul eax, dword ptr var1[ebp], 5 +mov ecx, dword ptr var2[ebp] +sub ecx, dword ptr var3[ebp] +xor edx, edx +div ecx +push eax +push offset strPrintfFmt +call _printf +add esp, 8 +push 0 +call ExitProcess +_main endp +end _main \ No newline at end of file diff --git a/1.2.asm b/1.2.asm new file mode 100644 index 0000000..4ba5830 --- /dev/null +++ b/1.2.asm @@ -0,0 +1,44 @@ +.686p +.model flat +include kernel32.inc +includelib kernel32.lib +includelib msvcrt.lib +extern _printf:proc +extern _scanf:proc +extern _strlen:proc +.data +strScanfFmt db "%d%d%d",0 +strPrintfFmt db "%d",0 +.code +_main proc +var1=-4 +var2=-8 +var3=-12 +mov ebp, esp +sub esp, 12 +lea edx, dword ptr [ebp+var3] +push edx +lea edx, dword ptr [ebp+var2] +push edx +lea edx, dword ptr [ebp+var1] +push edx +push offset strScanfFmt +call _scanf +add esp, 16 +imul ecx, dword ptr var1[ebp], -5 +mov eax, dword ptr var2[ebp] +neg eax +cdq +idiv dword ptr var3[ebp] +mov ebx, edx +mov eax, ecx +cdq +idiv ebx +push eax +push offset strPrintfFmt +call _printf +add esp, 8 +push 0 +call ExitProcess +_main endp +end _main \ No newline at end of file diff --git a/1.3.asm b/1.3.asm new file mode 100644 index 0000000..adc8c53 --- /dev/null +++ b/1.3.asm @@ -0,0 +1,41 @@ +.686p +.model flat +include kernel32.inc +includelib kernel32.lib +includelib msvcrt.lib +extern _printf:proc +extern _scanf:proc +extern _strlen:proc +.data +strScanfFmt db "%d",0 +strPrintfFmt db "%d",0 +.code +sgn proc +xor eax, eax +mov ebx, -1 +mov ecx, 1 +cmp dword ptr [esp+4], 0 +cmovl eax, ebx +cmovg eax, ecx +ret +sgn endp +_main proc +var1=-4 +mov ebp, esp +sub esp, 4 +lea edx, dword ptr var1[ebp] +push edx +push offset strScanfFmt +call _scanf +add esp, 8 +push dword ptr var1[ebp] +call sgn +add esp, 4 +push eax +push offset strPrintfFmt +call _printf +add esp, 8 +push 0 +call ExitProcess +_main endp +end _main \ No newline at end of file diff --git a/1.4.asm b/1.4.asm new file mode 100644 index 0000000..241434b --- /dev/null +++ b/1.4.asm @@ -0,0 +1,62 @@ +.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 \ No newline at end of file