delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/02/08/13:45:32

From: buers AT gmx DOT de (Dieter Buerssner)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Inline asm translations?
Date: 8 Feb 2000 18:23:08 GMT
Lines: 64
Message-ID: <87pmub$c18b$1@fu-berlin.de>
References: <Pine DOT SUN DOT 3 DOT 91 DOT 1000207183712 DOT 20861E-100000 AT is>
NNTP-Posting-Host: dialup-212.162.13.131.frankfurt1.mik.net (212.162.13.131)
Mime-Version: 1.0
X-Trace: fu-berlin.de 950034188 394507 212.162.13.131 (16 [17104])
X-Posting-Agent: Hamster/1.3.8.0
User-Agent: Xnews/2.11.08
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019