Mail Archives: djgpp/2000/02/07/12:13:15
On Mon, 7 Feb 2000, Jan-Jaap Severs wrote:
> void FillDoubleBuffer( int color )
> {
> asm {
> mov cx, double_buffer_size
> mov al, BYTE PTR color
> mov ah, al
> les di, double_buffer
> rep stosw
> }
> }
Why can't you use memset? That's exactly what it does, and GCC will
inline it automatically (if you compile with optimizations).
> And another one:
>
> asm {
> les di, dest_addr
> mov al, BYTE PTR color
> mov ah, al
> mov cx, xe
> sub cx, xs
> inc cx
> shr cx, 1
> rep stosw
> }
This is also memset, except that it does some simple arithmetics on the
number of bytes to set.
I suggest to use C library functions wherever you can, instead of getting
yourself into complications and portability problems with inline assembly.
- Raw text -