Mail Archives: djgpp/2001/08/28/10:45:21
From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: problem in inline assembler
|
Date: | 28 Aug 2001 10:33:08 GMT
|
Organization: | Aachen University of Technology (RWTH)
|
Lines: | 39
|
Message-ID: | <9mfs14$nqv$1@nets3.rz.RWTH-Aachen.DE>
|
References: | <9mfivi$j0g$1 AT news DOT nuri DOT net>
|
NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de
|
Mime-Version: | 1.0
|
X-Trace: | nets3.rz.RWTH-Aachen.DE 998994788 24415 137.226.32.75 (28 Aug 2001 10:33:08 GMT)
|
X-Complaints-To: | abuse AT rwth-aachen DOT de
|
NNTP-Posting-Date: | 28 Aug 2001 10:33:08 GMT
|
Originator: | broeker@
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
"±θΗΠΑΦ" <kimguy00 AT orgio DOT net> wrote:
> and I thought %0, %1, %2.. are just a kind of a mapping sequencely.
They are. The sequence is just counting a bit differently from what
you seemt expect: it counts constraints, not C variables mentioned in
them. The idea is that GCC will evaluate those expressions
(optimizing the evaluation as it sees fit, possibly mixing the inline
assembly statements with the generated statements), and make them
available to the assembly by substituting some register name or memory
address on the stack for the %0...%1 operands.
You may want to have a look at the generated assembly (gcc -O2 -S) to
see how this works out.
> So I thought %0 is gate_addr, %1 is dpl, %2 is type
No.
%0 is (*((long *)(gate_addr)))
%1 is (*(1+(long*)(gate_addr)))
%2 is ((short) (0x8000+(dpl<<13)+(type<<8)))
%3 is ((char *) (addr)),"a" (KERNEL_CS << 16)
> #define _set_gate(gate_addr,type,dpl,addr) \
> __asm__ __volatile__ ("movw %%dx,%%ax\n\t" \
> "movw %2,%%dx\n\t" \
> "movl %%eax,%0\n\t" \
> "movl %%edx,%1" \
> :"=m" (*((long *) (gate_addr))), \
> "=m" (*(1+(long *) (gate_addr))) \
> :"i" ((short) (0x8000+(dpl<<13)+(type<<8))), \
> "d" ((char *) (addr)),"a" (KERNEL_CS << 16) \
> :"ax","dx")
--
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.
- Raw text -