Assembler optimalisation - how to avoid a jump? (Developers)
> >shr ecx,1;rep movsd;adc ecx,ecx;rep movsw {fast 32bit write}
> If I want to transfer 2 pixels than I move 4 bytes. So:
> 2 shr 1 = 1 (and CF is set to zero)
>
> REP MOVSD with ECX=1 does one pass of dword transfer so two pixels are
> moved
> After this ECX is guaranted to be zero. And because CF is zero too, after
> ADC ECX,ECX is ECX still zero. Then...
> REP MOVSW with ECX=0 SKIPS THE TRANSFER
>
> That is how this piece works.
The fast move routine that I use is the SSE (move_JOH_SSE_10) routine in the archive on this side:
http://fastcode.sourceforge.net/
(the results of some runtime optimization contests for Delphi, most of them flowed into D2006, but for more specialistic uses I still browse through them, even if slightly outdated)
I also use it for images (but my rowlengths are typically long, 2048 1-byte pixels etc). We have a athlon64/core2 minimum though.
Note that afaik it is common to first align with a few movsb , and then do the bulk with the largest granularity move aligned, and then maybe another few odd ones.
Complete thread:
- Assembler optimalisation - how to avoid a jump? - Laaca, 13.05.2012, 20:38 (Developers)
![Open in board view [Board]](img/board_d.gif)
![Open in mix view [Mix]](img/mix_d.gif)
- Assembler optimalisation - how to avoid a jump? - Rugxulo, 13.05.2012, 21:10
- Assembler optimalisation - how to avoid a jump? - Laaca, 13.05.2012, 22:15
- Assembler optimalisation - how to avoid a jump? - marcov, 13.05.2012, 23:22
- Assembler optimalisation - how to avoid a jump? - Laaca, 13.05.2012, 22:15
- Assembler optimisation - how to avoid a jump? - ecm, 13.05.2012, 23:32
- Assembler optimisation - how to avoid a jump? - Laaca, 14.05.2012, 18:15
- Assembler optimisation - variant 3, sbb - ecm, 14.05.2012, 18:22
- Assembler optimisation - how to avoid a jump? - Rugxulo, 16.05.2012, 10:34
- Assembler optimisation - how to avoid a jump? - bretjohn, 16.05.2012, 16:42
- Assembler optimisation - speed, size, etc - ecm, 16.05.2012, 16:59
- Assembler optimisation - how to avoid a jump? - bretjohn, 16.05.2012, 16:42
- Assembler optimisation - how to avoid a jump? - Laaca, 14.05.2012, 18:15
- Assembler optimalisation - how to avoid a jump? - Rugxulo, 13.05.2012, 21:10
Mix view