delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1994/01/17/15:18:37

Date: 17 Jan 1994 12:08:12 -0800 (PST)
From: Gregory Eakin <XGEAKIN AT CCVAX DOT FULLERTON DOT EDU>
Subject: Re: IDTR and GDTR bases in go32
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Cc: ptan AT compudyn DOT com

 
Dear Paul,
    Here is what the GDT and IDT look like under djgpp.
 
#include <stdio.h>
 
typedef struct {
    unsigned int base    : 32;
    unsigned int limit   : 16;
    unsigned int filler  : 16;
} IDTR;
typedef struct {
    unsigned int base    : 32;
    unsigned int limit   : 16;
    unsigned int filler  : 16;
} GDTR;
typedef struct {
    unsigned int limit   : 16;
    unsigned int base    : 24;
    unsigned int filler  :  7;
    unsigned int present :  1;
    unsigned int limit2  :  4;
    unsigned int filler2 :  4;
    unsigned int base2   :  8;
} LDTR;
 
IDTR idtr;
GDTR gdtr;
LDTR ldtr;
unsigned char xxxx[8];
 
int main() {
    int i;
    asm ("sidt _idtr");
    asm ("sgdt _gdtr");
    asm ("sldt _ldtr");
    printf("idtr base = 0x%08x, limit = 0x%04x\n",idtr.base,idtr.limit);
    printf("gdtr base = 0x%08x, limit = 0x%04x\n",gdtr.base,gdtr.limit);
    printf("ldtr base = 0x%08x, limit = 0x%04x\n",
        ldtr.base|(ldtr.base2<<24), ldtr.limit|(ldtr.limit2<<16));
    /* This shows how the bytes are backwards! */
    asm ("sidt _xxxx");
    printf("idtr = ");
    for (i=0; i<8; i++) printf("0x%02x ", xxxx[i]); printf("\n");
    return 0;
}

-- Greg

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019