#include "stdafx.h"
#include <conio.h>
#include <ctime>
#include <thread>
#define MAX_I 4000000
unsigned __int32 rezult[64];
std::thread* thr[8];
void StartPR(int str)
{
int i = MAX_I;
int x = str;
__asm {
mov eax, MAX_I
xor ebx, ebx
xor ecx, ecx
xor edx, edx
circle:
dec eax
mov i, eax
add ebx, i
add ecx, i
add edx, i
cmp eax, 0
jnz circle
mov eax, x
mov esi, eax
mov [rezult + esi], eax
add esi, 4
mov [rezult + esi], ebx
add esi, 4
mov [rezult + esi], ecx
add esi, 4
mov [rezult + esi], edx
}
}
void StartMMX(int str)
{
int i = MAX_I;
int x = str;
_asm {
mov eax, MAX_I
//fldz
xor ebx, ebx
//fldz
xor ecx, ecx
circle2:
dec eax
mov i, eax
add ecx, i
add ebx, i
//fincstp
//fld i
//fadd st(1), st(0)
//fadd st(2), st(0)
cmp eax, 0
jnz circle2
mov eax, x
mov esi, eax
mov dword ptr[rezult + esi], ebx
add esi, 4
//fstp [rezult + esi]
add esi, 4
mov dword ptr[rezult + esi], ecx
add esi, 4
//fstp [rezult + esi]
}
}
void stardThreads(int numOfThread)
{
printf("threads: %i", numOfThread);
int i = 0;
clock_t strt = clock();
for (int i = 1; i < numOfThread; i++)
{
thr[i] = new std::thread(StartPR, i * 32);
}
StartPR(0);
clock_t strt2 = clock();
clock_t bk1 = strt2 - strt;
i = 16;
for (int i = 1; i < numOfThread; i++)
{
thr[i] = new std::thread(StartMMX, i * 32 + 16);
}
StartMMX(i);
clock_t bk2 = clock() - strt2;
printf("time block1:%i, block2:%i, tics per second:%i\n", (__int32)bk1, (__int32)bk2, CLOCKS_PER_SEC);
//for (int i = 0; i < numOfThread * 8; i++)
//printf("rezult[%i] = %u \n", i, rezult[i]);
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 1; i < 9; i++)
stardThreads(i);
_getch();
return 0;
}
clock_t strt2 = clock();
clock_t bk1 = strt2 - strt;
...
clock_t bk2 = clock() - strt2;
#include "stdafx.h"
#include <conio.h>
#include <ctime>
#include <thread>
#define MAX_I 4000000
unsigned __int32 rezult[64];
std::thread* thr[8];
void StartPR(int str)
{
int i = MAX_I;
int x = str;
__asm {
mov eax, MAX_I
xor ebx, ebx
xor ecx, ecx
xor edx, edx
circle:
dec eax
mov i, eax
add ebx, i
add ecx, i
add edx, i
cmp eax, 0
jnz circle
mov eax, x
mov esi, eax
mov [rezult + esi], eax
add esi, 4
mov [rezult + esi], ebx
add esi, 4
mov [rezult + esi], ecx
add esi, 4
mov [rezult + esi], edx
}
}
void StartMMX(int str)
{
int i = MAX_I;
int x = str;
_asm {
mov eax, MAX_I
fldz
xor ebx, ebx
fldz
xor ecx, ecx
circle2:
dec eax
mov i, eax
add ecx, i
add ebx, i
fincstp
fld i
fadd st(1), st(0)
fadd st(2), st(0)
cmp eax, 0
jnz circle2
mov eax, x
mov esi, eax
mov dword ptr[rezult + esi], ebx
add esi, 4
fstp [rezult + esi]
add esi, 4
mov dword ptr[rezult + esi], ecx
add esi, 4
fstp [rezult + esi]
}
}
void stardThreads(int numOfThread)
{
printf("threads: %i", numOfThread);
int i = 0;
clock_t strt = clock();
for (int i = 1; i < numOfThread; i++)
{
thr[i] = new std::thread(StartPR, i * 32);
}
StartPR(0);
clock_t bk1 = clock() - strt;
i = 16;
for (int i = 1; i < numOfThread; i++)
{
thr[i] = new std::thread(StartMMX, i * 32 + 16);
}
StartMMX(i);
clock_t bk2 = clock() - bk1;
printf("time block1:%i, block2:%i, tics per second:%i\n", (__int32)bk1, (__int32)bk2, CLOCKS_PER_SEC);
//for (int i = 0; i < numOfThread * 8; i++)
//printf("rezult[%i] = %u \n", i, rezult[i]);
}
int _tmain(int argc, _TCHAR* argv[])
{
for (int i = 1; i < 9; i++)
stardThreads(i);
_getch();
return 0;
}
switch(i){
case 1:
i++;
break;
case 2:
i+=2;
break;
case 3:
i+=3;
break;
default:
i+=4;
}
004010AE: 8B4DFC mov ecx, [ebp-04]
004010B1: 8BC1 mov eax, ecx
*switch
004010B3: 48 dec eax
004010B4: 7419 je 004010CF
004010B6: 48 dec eax
004010B7: 740F je 004010C8
004010B9: 48 dec eax
004010BA: 7405 je 004010C1
004010BC: 83C104 add ecx, 00000004
004010BF: EB13 jmp 004010D4
*end switch
* Jump:
004010BA(C)
004010C1: B906000000 mov ecx, 00000006
004010C6: EB0C jmp 004010D4
* Jump:
004010B7(C)
004010C8: B904000000 mov ecx, 00000004
004010CD: EB05 jmp 004010D4
* Jump:
004010B4(C)
004010CF: B902000000 mov ecx, 00000002
* Jump:
004010BF(U), 004010C6(U), 004010CD(U)
004010D4: 51 push ecx
Ну и кроме того, VS - просто удобно. Не нашел iDE со схожим функционалом на Линуксе. Подскажите - буду рад.