delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/03/10/11:05:12

Xref: news2.mv.net comp.os.msdos.djgpp:1765
From: Shawn Hargreaves <slh100 AT york DOT ac DOT uk>
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: <Pine.SGI.3.91.960310091342.26365F-100000@tower.york.ac.uk>
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
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 <mdm1004 AT cus DOT cam DOT ac DOT uk> 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?

- Raw text -


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