Guest User

Untitled

a guest
Jan 23rd, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MPASM 1.11 KB | None | 0 0
  1. ;wine ml.exe -c -coff % && wine link.exe /subsystem:windows %<.obj && wine %<.exe
  2. .686
  3. .model flat,stdcall
  4. include c:\masm32\include\kernel32.inc
  5. includelib c:\masm32\lib\kernel32.lib
  6. include c:\masm32\include\user32.inc
  7. includelib c:\masm32\lib\user32.lib
  8. .data
  9.     massiv dd 4,1,4,9,1,6,28
  10.     len equ $-massiv
  11.     MsgTitle  db 'Результат',0
  12.     Msg db 'Кол-во элементов > среднего ариф.: '
  13.     res db 20 dup(0)
  14.     szformat db "%u", 0
  15. .code
  16.     jmp start
  17.  
  18. compute proc ; DWORD sred(DWORD* massiv, DWORD size)
  19.     mov ebx, dword ptr [esp+4]
  20.     mov ecx, dword ptr [esp+8]
  21.     mov eax, ecx
  22.     xor esi, esi
  23.  
  24.     jmp summa
  25. tmp:
  26.     dec eax
  27.     add esi, dword ptr [ebx+eax*4]
  28. summa:
  29.     or eax, eax
  30.     jnz tmp
  31. ;srednee
  32.     mov eax, esi
  33.     xor edx, edx
  34.     div ecx
  35.  
  36.     mov esi, eax
  37.     xor eax, eax
  38.     jmp tmp2
  39. otvet:
  40.     dec ecx
  41.     cmp esi, dword ptr [ebx+ecx*4]
  42.     adc eax, 0
  43. tmp2:
  44.     or ecx, ecx
  45.     jnz otvet
  46.     ret 8
  47. compute endp
  48.  
  49. start:
  50.     push len/4
  51.     push offset massiv
  52.     call compute
  53.  
  54.     invoke wsprintf, offset res, offset szformat, eax
  55.     invoke MessageBoxA,0,offset Msg,offset MsgTitle,0
  56.     invoke ExitProcess, 0
  57. end start
Add Comment
Please, Sign In to add comment