Mail Archives: djgpp/2000/02/08/13:45:32
djgpp AT delorie DOT com (Eli Zaretskii) wrote in
<Pine DOT SUN DOT 3 DOT 91 DOT 1000207183712 DOT 20861E-100000 AT is>:
>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).
I agree with your advice about using memset. But, are you sure
about the inlining. I must be doing something wrong. (Note, that
in the above example, double_buffer_size seems not to be a
compile time constant.)
This is with gcc 2.95.2:
E:\test>cat memset.c
#include <string.h>
void foo(void *p, unsigned int n)
{
memset(p,0,n);
/* Do something useful */
}
E:\test>gcc -O3 -S memset.c
E:\test>cat memset.s
.file "memset.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
.p2align 2
.globl _foo
_foo:
pushl %ebp
movl %esp,%ebp
subl $8,%esp
movl 8(%ebp),%edx
movl 12(%ebp),%eax
addl $-4,%esp
pushl %eax
pushl $0
pushl %edx
call _memset
movl %ebp,%esp
popl %ebp
ret
Regards,
Dieter
- Raw text -