Chinaunix首页 | 论坛 | 博客
  • 博客访问: 943949
  • 博文数量: 116
  • 博客积分: 3923
  • 博客等级: 中校
  • 技术积分: 1337
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-23 01:22
文章分类

全部博文(116)

文章存档

2013年(1)

2012年(17)

2011年(69)

2009年(29)

分类: WINDOWS

2011-08-22 18:03:13





file:main.c (VC6)
  1. #include <stdio.h>

  2. #ifdef WIN32
  3. #pragma pack(1)
  4. #define u16 unsigned short
  5. #define __attribute__(x)
  6. #endif

  7. #define GDT_ENTRY_INIT(flags, base, limit) { { { \
  8.     ((limit) & 0xffff) | (((base) & 0xffff) << 16), \
  9.     (((base) & 0xff0000) >> 16) | (((flags) & 0xf0ff) << 8) | \
  10.     ((limit) & 0xf0000) | ((base) & 0xff000000), \
  11.     } } }

  12. struct desc_struct {
  13.     union {
  14.         struct {
  15.             unsigned int a;
  16.             unsigned int b;
  17.         };
  18.         struct {
  19.             u16 limit0;
  20.             u16 base0;
  21.             unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
  22.             unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
  23.         };
  24.     };
  25. }__attribute__((packed));

  26. int main(int argc, char* argv[])
  27. {
  28.     struct desc_struct desc=GDT_ENTRY_INIT(0xF0FF,0xFFFFFFFF,0xFFFFF);
  29.     printf ("limit0:%d, base0:%d, base1:%d, type:%d, s:%d, dpl:%d, p:%d, limit:%d, avl:%d, l:%d, d:%d, g:%d, base2:%d\r\n",
  30.         desc.limit0,
  31.         desc.base0,
  32.         desc.base1,
  33.         desc.type,
  34.         desc.s,
  35.         desc.dpl,
  36.         desc.p,
  37.         desc.limit,
  38.         desc.avl,
  39.         desc.l,
  40.         desc.d,
  41.         desc.g,
  42.         desc.base2);
  43.     return 0;
  44. }

阅读(800) | 评论(0) | 转发(0) |
0

上一篇:[转]Linux 内核简介

下一篇:实现assert函数

给主人留下些什么吧!~~