, , .
, , , ,
400600: 8d 04 37 lea (%rdi,%rsi,1),%eax
400603: c3 retq
400610: 89 f8 mov %edi,%eax
400612: 21 f0 and %esi,%eax
400614: c3 retq
, , , . , .
, zillion , . , , .
.balign 32
nop
.balign 256
.globl and_test
and_test:
mov %edi,%eax
and %esi,%eax
sub $1,%edx
jne and_test
retq
.balign 32
nop
.balign 256
.globl add_test
add_test:
mov %edi,%eax
add %esi,%eax
sub $1,%edx
jne add_test
retq
.balign 256
nop
#include<stdio.h>
#include<time.h>
unsigned int add_test ( unsigned int a, unsigned int b, unsigned int x );
unsigned int and_test ( unsigned int a, unsigned int b, unsigned int x );
int main()
{
int x=10;
int y=25;
time_t start,stop;
for(int j=0;j<10;j++)
{
start = clock();
add_test(10,25,2000000000);
stop = clock();
printf("%u %u\n",j,(int)(stop-start));
}
for(int j=0;j<10;j++)
{
start = clock();
and_test(10,25,2000000000);
stop = clock();
printf("%u %u\n",j,(int)(stop-start));
}
return(0);
}
, , , ? , , , ...
0 605678
1 520204
2 521311
3 520050
4 521455
5 520213
6 520315
7 520197
8 520253
9 519743
0 520475
1 520221
2 520109
3 520319
4 521128
5 520974
6 520584
7 520875
8 519944
9 521062
. , .
0 599558
1 515120
2 516035
3 515863
4 515809
5 516069
6 516578
7 516359
8 516170
9 515986
0 516403
1 516666
2 516842
3 516710
4 516932
5 516380
6 517392
7 515999
8 516861
9 517047
, 2 . . 1000000 3.4ghz 0.8772 0.2193 , ? .
, , , , , ( ), .
- , , -, /, , . , , , sram, .., , , , , .. ( , 10 , , , x86. , x86 - , , x86 , )
, , , (TODO).
https:
https:
, / , , , /. , , , AND.... ... , ( vs add//xor/etc, , , , ). , ( ) , ββ .. - , /, , / . (), , , , , , 4ghz, 2,7, . , vs , , , , , pspice , , , , - , , pspice .
-, , ,
this
a = b+c+d+e+f+g;
vs
x=b+c;
y=d+e;
z=f+g;
a=x+y;
a=a+z;
5 , 5 , . , . ( x, y, z , a = x + y + z , )
, , , , , . , . 0 1 . - , . , , . ... , ( / ) . x86 IP- , , , , , , , , , alu.
, vs add/ , , , , , , , , , -. - - , , , - , .