📄 extend.c
字号:
#include "bios.h"
#include "dos.h"
#include "stdio.h"
#define ATTDW 0x92
#define ATTDR 0x90
#define SELECTOR_1 8
#define SELECTOR_2 16
#define GDTNUM 3
asm .386p
struct descriptor
{
int limitl;
int basel;
char basem;
int attr;
char baseh;
};
struct pdesc
{
int limit;
long base;
};
struct descriptor gdt[]={{0,0,0,0,0},{0xffff,0xffe0,0x10,ATTDW+0x8f00,0},{0xffff,0xf000,0xff,ATTDR,0}};
struct pdesc vgdt;
void opena20()
{
asm push ax
asm in al,92h
asm or al,2
asm out 92h,al
asm pop ax
}
void envir_4gb()
{
asm cli
asm push ds
asm mov word ptr vgdt.limit,GDTNUM*8-1
asm xor eax,eax
asm mov ax,ds
asm shl eax,4
asm xor ebx,ebx
asm lea bx, gdt
asm add eax,ebx
asm mov dword ptr vgdt.base,eax
asm lgdt qword ptr vgdt
asm mov eax,cr0
asm or al,1
asm mov cr0,eax
asm jmp virtual
virtual:
asm mov ax,SELECTOR_1
asm mov gs,ax
asm mov ax,SELECTOR_2
asm mov fs,ax
asm and al,0feh
asm mov cr0,eax
asm jmp real
real:
asm pop ds
asm sti
}
main()
{unsigned long i,temp;
opena20();
envir_4gb();
for (i=0;i<0xf;i+=4)
{
asm mov ebx,i
asm mov eax,fs:[ebx]
asm mov temp,eax
printf("%lx ",temp);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -