Mail Archives: djgpp/1996/03/10/11:05:12
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 -