gcc pointer problem in osdev
Posted: Tue Nov 10, 2009 10:31 pm
Hi, I have a strange question....
In a function:
Variable a is one argument of the function, so when I let pointer p = address of a, gcc generate an instruction:
Next line, I want to find a with p, gcc generate another instruction:
When I get the address, LEA instruction put the effective address of a into edi, segment register is SS; but when I want the value, MOV instruction use a segment register DS........
So if DS != SS, the answer is wrong.... now I have to set DS = SS, this confuse me very much.
Does gcc generate a wrong code ?
Is that some gcc argument or other ways can solve this problem?
In a function:
Code: Select all
void fun(int a){
int *p = &a;
putd(*p);
}
Code: Select all
lea edi, ss:[xx+xx]
Code: Select all
mov eax, ds:[edi+x]
So if DS != SS, the answer is wrong.... now I have to set DS = SS, this confuse me very much.
Does gcc generate a wrong code ?
Is that some gcc argument or other ways can solve this problem?