clobbered registers



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

.



Relevant Pages

  • Re: Programming 8254 timer chip
    ... This transfers the current value of counter register of timer 0 into the ... Reads the low byte of the latch register into 'cv'. ... reload value, but when the reload is at its normal value then you ... BiosTicks: Longint absolute $0040:006C; ...
    (comp.os.msdos.programmer)
  • Re: Programming 8254 timer chip
    ... Ayon kay Jason Burgon: ... This transfers the current value of counter register of timer 0 into the ... Reads the low byte of the latch register into 'cv'. ... reload value, but when the reload is at its normal value then you ...
    (comp.os.msdos.programmer)
  • Re: Help understanding uops, etc...
    ... > using ECX as my counter instead of EDX sounds intriguing but with my ... They only support using immediates or the cl register. ... You mean esp, and yes, it is faster because you now have another register to ... When you do push/pop items from the stack, ...
    (comp.lang.asm.x86)
  • Re: looping through array in gas
    ... You might be confusing AT&T and Intel syntax. ... The indexpointer is any register except esp. ... into edx, right? ... shouldn't be thought of as an actually a memory address or reference. ...
    (comp.lang.asm.x86)
  • Re: XP pro register licence afetr 90 days - loops on xp login
    ... How to Perform a Windows XP Repair Install ... Would you like to register now?" ... Apart form a full clean xp reload, how can we get his pc ...
    (microsoft.public.windowsxp.general)