Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctime>
- #include <iomanip>
- using namespace std;
- // Laboratorium 5
- // Suma elementów macierzy
- void print(int **p, int n, int m){
- for (int i = 0; i < n; i++){
- for (int j = 0; j < m; j++){
- cout << setw(4) << p[i][j] << " ";
- }
- cout << endl;
- }
- cout << endl;
- }
- int main()
- {
- srand((unsigned)time(0));
- int n = 3;
- int m = 2;
- int **a = new int *[n];
- int test = 0;
- int suma = 0;
- for (int i = 0; i < n; i++){
- a[i] = new int[m];
- for (int j = 0; j < m; j++){
- a[i][j] = rand() % 10;
- test += a[i][j];
- }
- }
- cout << "macierz a: " << endl;
- print(a, n, m);
- cout << endl;
- __asm {
- pushad
- pushfd
- xor eax, eax
- mov ecx, n
- _petla :
- mov esi, a // **a macierz
- mov esi, dword ptr [esi + 4 * ecx - 4] // *a tablica
- push ecx
- mov ecx, m
- _petla2:
- add eax, dword ptr [esi + 4 * ecx - 4]
- loop _petla2
- pop ecx
- loop _petla
- mov suma, eax
- popfd
- popad
- }
- cout << "[C++]:" << test << endl;
- cout << "[ASM]:" << suma << endl;
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement