Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Assembler optimalisation - how to avoid a jump? (Developers)

posted by Laaca(R) Homepage, Czech republic, 13.05.2012, 22:15

>shr ecx,1;rep movsd;adc ecx,ecx;rep movsw {fast 32bit write}

It is nice piece of code I think.
ECX is number ox pixels to plot. I forgot to mention that I draw in 16bpp mode
so one pixel are two bytes.

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...

That is how this piece works.



Complete thread:

Back to the forum
Board view  Mix view
15317 Postings in 1383 Threads, 254 registered users, 15 users online (1 registered, 14 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum