Mail Archives: djgpp/1997/07/16/20:30:41
Jeff Weeks wrote:
> Here it is:
>
void aligned_dwords(int x1, int x2, int y, unsigned char c) {
unsigned long col;
> if(x1 == x2) return;
/* let gcc 'longise' c so it can pick the registers (use -O or -O2)
*/
col=(c<<8)|c;
col=(col<<16)|col;
> if(x1 > x2) {
> x1 ^= x2;
> x2 ^= x1;
> x1 ^= x2;
> }
>
> __asm__ __volatile__("
# %eax,%edi,%ecx already initialised
> test $1, %%edi;
> jz 0f;
> stosb;
# dec %%cx; not needed (should be ecx anyway)
> 0:
# movl %%edi, %%ebx; no longer needed
testl $2, %%edi; # is edi dword aligned?
> jz 1f;
> stosw;
> 1:
shr $2, %%ecx; # should be ecx rather than cx (saves a byte and
maybe a cylcle)
rep; stosl" /* uses ecx as the count (this comment is out side
the quotes) */
> :
: "D" (0xA0000+__djgpp_conventional_base+y*320+x1), "a" (col), "c"
((long)(x2-x1))
: "ecx", "edi", "memory"
> );
> }
Any lines I've added or modifed have the '>' removed. I've commented
out or removed (the settup of eax) code that isn't needed.
Other than the few things, it was pretty good code IMO.
Hope this helps (also demonstrates how to comment inline asm).
Bill
--
Leave others their otherness.
- Raw text -