From: shikamuk on
Hello
I wonder which way is faster while doing arithmetical expressions.
For example, I can add to allocated variables, and I can move them to
the registers and then add.
Probably, addition in the registers is faster. But what about time to
move them to the registers?

Thanks
From: almas on
If you have informations about the instructions....
you can know how many clock the computer will use

You can also catch the real time
date, time ( hour minute secon, hundered of seconnds
at the begining of a test.....
you do 65 000 the same operation
you do it millions time if necessary....

and then calulate again the time

Then compare the date after and before the test.

I use this method


<shikamuk(a)gmail.com> a �crit dans le message de news:
8fc265ef-c8ea-4395-8cfa-aa988115113e(a)d70g2000hsb.googlegroups.com...
> Hello
> I wonder which way is faster while doing arithmetical expressions.
> For example, I can add to allocated variables, and I can move them to
> the registers and then add.
> Probably, addition in the registers is faster. But what about time to
> move them to the registers?
>
> Thanks


From: Robert Redelmeier on
shikamuk(a)gmail.com wrote in part:
> I wonder which way is faster while doing arithmetical expressions.
> For example, I can add to allocated variables, and I can move them
> to the registers and then add. Probably, addition in the registers
> is faster. But what about time to move them to the registers?

x86 doesn't have any instructions to add memory to memory.
It can add registers together, or memory to registers or
even register to memory.


-- Robert

From: Wolfgang Kern on

shikamuk asked:

> Hello
> I wonder which way is faster while doing arithmetical expressions.
> For example, I can add to allocated variables, and I can move them to
> the registers and then add.
> Probably, addition in the registers is faster.
> But what about time to move them to the registers?

Every memory access takes its time, also if already cached or on stack.

ADD [mem],... is a good example of a READ-MODIFY-WRITE sequence,
and it is faster than its discrete replacement:

MOV eax,[var1]
MOV ebx,[var2]
ADD eax,ebx
MOV [var1],eax

is much slower than:

MOV eax,[var2]
ADD [var1],eax

but it also depends on where you want the result
ie:

MOV eax,[var2]
ADD eax,[var1]

is a few micro-cycles faster than with [mem] as result destination.

__
wolfgang



From: //o//annabee on
P� Thu, 10 Jan 2008 03:35:06 -0800, skrev Wolfgang Kern <nowhere(a)never.at>:

>
> shikamuk asked:
>
>> Hello
>> I wonder which way is faster while doing arithmetical expressions.
>> For example, I can add to allocated variables, and I can move them to
>> the registers and then add.
>> Probably, addition in the registers is faster.
>> But what about time to move them to the registers?
>
> Every memory access takes its time, also if already cached or on stack.
>
> ADD [mem],... is a good example of a READ-MODIFY-WRITE sequence,
> and it is faster than its discrete replacement:
>
> MOV eax,[var1]
> MOV ebx,[var2]
> ADD eax,ebx
> MOV [var1],eax
>
> is much slower than:
>
> MOV eax,[var2]
> ADD [var1],eax

on AMD64, they are identical.

>
> but it also depends on where you want the result
> ie:
>
> MOV eax,[var2]
> ADD eax,[var1]
>
> is a few micro-cycles faster than with [mem] as result destination.



>
> __
> wolfgang
>
>
>



--
http://www.youtube.com/watch?v=pZ6zzE8JUGY
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8 9 10 11
Prev: A little ASM 6809 program
Next: what is rsrc.rc?