Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- int _tmain(int argc, _TCHAR* argv[])
- {
- int Array[1000], tmp, N;
- N = 1000;
- for (int i = 0; i < 1000; i++)
- {
- Array[i] = rand()%1000;
- }
- tmp = 0;
- clock_t begin, end;
- double time_spent;
- begin = clock();
- for (int i = 0; i < 999; i++)
- {
- for (int j = 0; j < 999; j ++)
- {
- if(Array[j] > Array [j+1])
- {
- tmp = Array[j];
- Array[j] = Array[j + 1];
- Array[j + 1] = tmp;
- }
- }
- }
- end = clock();
- time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
- printf(" Czas T1 c: %lf \n",time_spent);
- for (int i = 0; i < 1000; i++)
- {
- Array[i] = rand()%1000;
- }
- begin = clock();
- _asm{
- mov ECX, 1000
- xor EDI, EDI
- sortuj: mov ESI, 1000
- dec ESI
- przesuwanie_elementow: mov EAX, Array[ESI*1]
- dec ESI
- cmp Array[ESI*1],EAX
- jge dalej
- zamiana: mov EDX, Array[ESI*1]
- mov Array[ESI*1 + 1], EDX
- mov Array[ESI*1], EAX
- dalej: cmp ESI,EDI
- ja przesuwanie_elementow
- inc EDI
- loop sortuj
- };
- end = clock();
- time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
- printf(" Czas T2 asm: %lf \n",time_spent);
- system("PAUSE");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement