title: Reading a register of nonstandard size (IDTR) in inline assembly (easy?)
body: <p>I am just starting out trying to understand the linux kernel, and am trying to find the location of IDTR.  It <em>seems</em> like it should be a simple enough process, as the assembly language provides the <code>lidt</code> instruction for just this purpose.  I would think therefore, that I could provide a structure large enough to accommodate the contents of this register as an output operand, like so:</p>
  
  <pre><code>struct idt_ptr
  {
      unsigned short limit;
      unsigned long long base;
  } __attribute__((packed));
  
  struct idt_ptr idtp;
  
  int * get_idt() {
      __asm__
      __volatile__(
          "lidt %0;"
          : "=&amp;r"(idtp)
      );
  }
  </code></pre>
  
  <p>This doesn't work, of course.  It results in</p>
  
  <pre><code>/var/folders/yb/ybzqw8850nz9lzjsc6jf9hkw0000gn/T//ccvNm3SA.s:11:suffix or operands invalid for `lidt'
  </code></pre>
  
  <p>I <em>think</em> the size of the struct is correct, <code>short</code> should provide 16 bits for the segment address and <code>long long</code> 64 bits for the offset.  Is the problem simply that I can't use a struct as an output target?  How would I go about this otherwise?  Also, since resources (to my finding) have been kind of scarce, could anyone recommend a good tutorial or book on the subject?</p>
  
  <p>Thanks.</p>