Advertisement
Guest User

sesiune is coming...

a guest
Jan 18th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.55 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int estePrim(int)
  7. {
  8.   _asm {
  9.     mov ebx, [ebp + 8]
  10.     cmp ebx, 1
  11.     jle nuEstePrimSigur
  12.     mov ecx, 2
  13.     mov esi, 1
  14.     while1:
  15.     cmp ecx, ebx
  16.     jge stopwhile1
  17.     mov edx, 0
  18.     mov eax, ebx
  19.     div ecx
  20.     cmp edx, 0
  21.     je amGasitDivizor
  22.     inc ecx
  23.     jmp while1
  24.     amGasitDivizor:
  25.     dec esi
  26.     stopwhile1:
  27.     mov eax, esi
  28.     jmp eGata
  29.     nuEstePrimSigur:
  30.     mov eax, 0
  31.     eGata:
  32.   }
  33. }
  34.  
  35. int check(int *, int)
  36. {
  37.   _asm {
  38.     mov ecx, [ebp + 8]
  39.     mov ebx, [ebp + 12]
  40.     mov eax, ebx
  41.     mul ebx
  42.     mov esi, 0
  43.     mov edi, 0
  44.     mov edx, 0
  45.     while1:
  46.     cmp edx, eax
  47.     jge stopwhile1
  48.     cmp edi, [ebp + 12]
  49.     jl justGo
  50.     mov edi, 0
  51.     inc esi
  52.     justGo:
  53.     mov ebx, esi
  54.     add ebx, edi
  55.     test ebx, 1
  56.     jz trebuiePus1
  57.     pushad
  58.     push ebx
  59.     call estePrim
  60.     pop ebx
  61.     cmp eax, 1
  62.     je trebuiePus2
  63.     popad
  64.     mov dword ptr [ecx + edx * 4], 3
  65.     inc edx
  66.     inc edi
  67.     jmp while1
  68.     trebuiePus2:
  69.     popad
  70.     mov dword ptr [ecx + edx * 4], 2
  71.     inc edx
  72.     inc edi
  73.     jmp while1
  74.     trebuiePus1:
  75.     mov dword ptr [ecx + edx * 4], 1
  76.     inc edx
  77.     inc edi
  78.     jmp while1
  79.     stopwhile1:
  80.   }
  81. }
  82.  
  83. int main()
  84. {
  85.   int m[3][3];
  86.   int n = 3;
  87.   _asm {
  88.     lea eax, m
  89.     push n
  90.     push eax
  91.     call check
  92.     add esp, 8
  93.   }
  94.  
  95.   for (int i = 0; i < n; ++i)
  96.   {
  97.     for (int j = 0; j < n; ++j)
  98.     {
  99.       cout << m[i][j] << ' ';
  100.     }
  101.     cout << '\n';
  102.   }
  103.  
  104.   return 0;
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement