|
Prev: A little ASM 6809 program
Next: what is rsrc.rc?
From: shikamuk on 9 Jan 2008 13:51 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 9 Jan 2008 17:28 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 9 Jan 2008 23:12 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 10 Jan 2008 06:35 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 10 Jan 2008 16:07
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 |