Re: clobbered registers
- From: Cyril Novikov <spamtrap@xxxxxxxxxx>
- Date: Sun, 30 Apr 2006 04:21:45 GMT
On 27.04.2006 5:18, luke wrote:
Hi everybody,
I'm trying to develop a little operating system,
but I can't resolve the following issue.
I have defined a macro which purpose is to set the base address of a
segment:
#define set_base(addr,base) \
__asm__("movw %%dx,%0\n\t" \
"rorl $16,%%edx\n\t" \
"movb %%dl,%1\n\t" \
"movb %%dh,%2" \
::"m" (*((addr)+2)), \
"m" (*((addr)+4)), \
"m" (*((addr)+7)), \
"d" (base) \
)
Here, gcc doesn't know that you've clobbered %edx in your code. In fact, this statement explicitly tells GCC that you DON'T clobber %edx. You either need to specify %edx both as input and output, or try to list it as a clobbered register, e.g.
....
"d"(base) : "%edx" \
....
However, I'm not sure that GCC is going to like that, since %edx is also listed as an input.
The problem is that when I use it in the following way:
set_base(ldt[1], code_base);
set_base(ldt[2], data_base);
the gcc compiler doesn't reload the edx register so I get a wrong
result.
Even with your code, if gcc doesn't think that code_base and data_base are the same for some reason, it should reload %edx. How are code_base and data_base declared?
--
Cyril
.
- References:
- clobbered registers
- From: luke
- clobbered registers
- Prev by Date: Re: msdos exe file loading related questions, answer as much as u can ;)
- Next by Date: Re: msdos exe file loading related questions, answer as much as u can ;)
- Previous by thread: Re: clobbered registers
- Next by thread: (ANNOUNCE) HLA Standard Library at SF
- Index(es):
Relevant Pages
|