Conflicting info

Programming, for all ages and all languages.
Post Reply
beyondsociety

Conflicting info

Post by beyondsociety »

I was looking through some code on setting up a idt in C and noticed something odd. When they set the idt function in at&t assembly, they show this:

Code: Select all

__asm__ __volatile__("lidt (%0)" : : "p" (&idtp));
So I looked on the osfaq under "inline assembly" but there was no mention of "p". So I was searching on google and came across a page on clobbered registers. This is what they show:
g - general effective address
m - memory effective address
r - register
i - immediate value, 0..0xffffffff
n - immediate value known at compile time.
("i" would allow an address known only at link time)

But there are some i386-specific ones described in the processor-specific
part of the manual and in more detail in GCC's i386.h:

q - byte-addressable register (eax, ebx, ecx, edx)
A - eax or edx
a, b, c, d, S, D - eax, ebx, ecx, edx, esi, edi respectively

I - immediate 0..31
J - immediate 0..63
K - immediate 255
L - immediate 65535
M - immediate 0..3 (shifts that can be done with lea)
N - immediate 0..255 (one-byte immediate value)
O - immediate 0..32
But no "p". Is the article wrong or is it supposed to be "q"?

Thanks in advance.
AR

Re:Conflicting info

Post by AR »

http://gcc.gnu.org/onlinedocs/gcc-3.3.1 ... aints.html

"p" is defined as an "address operand" (in other words, a pointer used with a "load" instruction). "m" would work just as well though.
User avatar
df
Member
Member
Posts: 1076
Joined: Fri Oct 22, 2004 11:00 pm
Contact:

Re:Conflicting info

Post by df »

the inline asm syntax changes from version to version.

I have this in one of my old files

Code: Select all

   // gcc 3.1 kludge
#if defined(__GNUC__) && (__GNUC__ == 3 && (__GNUC__ == 3 && __GNUC_MINOR__ == 1))
   asm volatile ("movl %%eax, %%eax\n" ::: "memory");   
   asm volatile ("lidt (%0)\n" :: "p" (((UINT8*)x)+2) : "memory" );
#else
   __asm__ __volatile__ ("lidt (%0)"::"d"((int)((UINT8*)x)+2):"memory");
#endif
I think p was for pointer? what I do know was that it worked.....
-- Stu --
beyondsociety

Re:Conflicting info

Post by beyondsociety »

"p" is defined as an "address operand" (in other words, a pointer used with a "load" instruction). "m" would work just as well though.
Thanks for the info. With a few modications I was able to get the load lidt function to work with my code. Cygwin was giving me a internal error whenever I would supply "p" in the lidt function. Once I figured out what "p" referred to, I was able to fix the problem (pointer issues).

Now, I just got to fix my exception handling code, and code up a keyboard driver.

By the way, the inline assembly page in the osfaq seems like more of a intro than a actual tutorial page. If I get a chance I may add more info to the page unless somebody beats me to it first. Also a few links to info would also be helpful.

Thanks in advance.
Post Reply