clobbered registers
- From: "luke" <spamtrap@xxxxxxxxxx>
- Date: 27 Apr 2006 05:18:15 -0700
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) \
)
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.
The code I get after disassemby is:
6133: 89 f2 mov %esi,%edx
6135: 66 89 93 52 01 00 00 mov %dx,0x152(%ebx)
613c: c1 ca 10 ror $0x10,%edx
613f: 88 93 54 01 00 00 mov %dl,0x154(%ebx)
6145: 88 b3 57 01 00 00 mov %dh,0x157(%ebx)
614b: 66 89 93 5a 01 00 00 mov %dx,0x15a(%ebx)
6152: c1 ca 10 ror $0x10,%edx
6155: 88 93 5c 01 00 00 mov %dl,0x15c(%ebx)
615b: 88 b3 5f 01 00 00 mov %dh,0x15f(%ebx)
as you can notice there is no reload of the register edx between the
two calls.
Some hints I can give you are:
1) I use gcc 3.4.4 with the following options:
-Wall -O -fstrength-reduce -fomit-frame-pointer -finline-functions
2) If I put some dummy code between the two calls all is working
correctly. For example:
set_base(ldt[1], code_base);
printk("dummy\n");
set_base(ldt[2], data_base);
3) I have tryed to add edx in the "clobbered registers list" but the
compiler complains about
"Can't find a register in class DREGS"
Thanks in advance
Luke Swanz
.
- Follow-Ups:
- Re: clobbered registers
- From: Cyril Novikov
- Re: clobbered registers
- From: Rod Pemberton
- Re: clobbered registers
- Prev by Date: Re: lea with fs override
- Next by Date: Re: MASM question...
- Previous by thread: Learning MMX
- Next by thread: Re: clobbered registers
- Index(es):
Relevant Pages
|