Xref: news2.mv.net comp.os.msdos.djgpp:1765 From: Shawn Hargreaves Newsgroups: comp.os.msdos.djgpp Subject: Re: ASM code & Random Date: Sun, 10 Mar 1996 09:21:56 +0000 Organization: The University of York, UK Lines: 57 Message-ID: References: <1996Mar5 DOT 164831 AT zipi DOT fi DOT upm DOT es> <4hn17p$bfs AT lyra DOT csx DOT cam DOT ac DOT uk> <4hnjl1$1l0 AT mack DOT rt66 DOT com> NNTP-Posting-Host: tower.york.ac.uk Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII In-Reply-To: <4hnjl1$1l0@mack.rt66.com> To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp On 7 Mar 1996, Brennan Mr. Wacko Underwood wrote: > M.D. Mackey wrote: > > >asm(" > > pushw %es > > pushl %edi > > pushl %esi > > pushl %ecx > > movl $0xa0000,%edi > > movl _virt,%esi # virt declared somewhere > > movl $16000,%ecx > > movw _dos_seg,%es > > rep > > movsl > > popl %ecx > > popl %esi > > popl %edi > > popw %es > >") > > Problems: > * 0xa0000 isn't AT 0xa0000, necessarily. And it's by default protected. Erm... I think you are wrong there :-) The movsl instruction moves to %es:[%edi], and since he put _dos_seg into %es, it will go to the correct address. > * need to use %%eax for %eax due to format of asm statement. That is only true if you are using the extended asm syntax with register parameters. In a simple asm (" instructions "); a single % is ok. I can see one problem in the above code, though. He refers to _dos_ds, which is the C symbol. In asm I think that needs an extra underbar, eg. __dos_ds. > * es always = ds, I believe. For DJGPP, at least. Yes, that is why he had to move _dos_ds into %es... > * pushing and popping the vars doesn't help GCC's optimizer at all True, but the overhead of pushing a couple of registers onto the stack is totally insignificant compared to the time it takes to copy a big chunk of memory to the screen. > I've been thinking of trying to get GCC to convert memset() to rep stosl > as well, but I don't know how to go about doing it. That would be a nice optimisation. Is the memcpy() an inline function in one of the headers? If so, which one? I can't find it anywhere... Shawn Hargreaves If God is omnipotent, can he make a http://www.york.ac.uk/~slh100/ rock so heavy that he cannot lift it?