upward
初级用户
积分 120
发帖 7
注册 2004-7-28
状态 离线
|
『第
6 楼』:
#include <dos.h>
#include <stdio.h>unsigned long GDT_Table[]= { 0,0, //NULL - 00H
0x0000FFFF,0x00CF9A00,
0x0000FFFF,0x00CF9200};
unsigned char OldIDT [6]={0};
unsigned char pdescr_tmp [6]={0};#define KeyWait() {while(inportb(0x64) &2);}void A20Enable(void)
{
KeyWait();
outportb(0x64,0xD1);
KeyWait();
outportb(0x60,0xDF);
KeyWait();
outportb(0x64,0xFF);
KeyWait();
} void LoadFSLimit4G(void)
{
A20Enable();
asm
{
cli // Disable inerrupts
sidt OldIDT // Save OLD IDTR
lidt pdescr_tmp // Set up empty IDT. Disable any interrupts
}
asm
{
db 0x66
mov cx, ds
db 0x66
shl cx, 4
mov word ptr pdescr_tmp[0],(3*8-1)
db 0x66
xor ax, ax
mov ax, offset GDT_Table
db 0x66
add ax, cx
mov word ptr pdescr_tmp [2], ax
db 0x66
shr ax, 16
mov word ptr pdescr_tmp [4], ax
lgdt pdescr_tmp
}
asm
{
mov dx, 0x10 // The Data32 Selector
db 0x66, 0x0f, 0x20, 0xc0 // mov eax, cr0
db 0x66
mov bx, ax
or ax, 1
db 0x66, 0x0f, 0x22, 0xc0
jmp flush
} // Clear machine perform cache.
flush: // Now In Flat Mode, But The CS is Real Mode Value.
asm
{
db 0x66
mov ax, bx
db 0x8e, 0xe2 // mov fs, dx
db 0x66, 0x0f, 0x22, 0xc0 // mov cr0, eax
lidt OldIDT
sti
}
}
unsigned char ReadByte (unsigned long Address)
{
asm db 0x66
asm mov di,word ptr Address // MOV EDI, Address
asm db 0x67 //32 bit Address Prefix
asm db 0x64 //FS:
asm mov al,byte ptr [BX] // =MOV AL, FS: [EDI]
return _AL;
}
unsigned char WriteByte(unsigned Long Address)
{
asm db 0x66
asm mov di,word ptr Address //MOV EDI, Address
asm db 0x67 //32 bit Address Prefix
asm db 0x64 //FS:
asm mov byte ptr [BX],al //=MOV FS: [EDI],AL
return _AL;
}
//////// Don t Touch Above Code ///
void Dump4G(unsigned long Address)
{
int i;
int j;
for(i=0; i<20; i++)
{
printf("%081X: ", (Address+i*16));
for(j=0; j<16; j++)
printf("% 02X", ReadByte(Address+i*16+j));
printf(" "
for(j=0; j<16; j++)
{
if(ReadByte(Address+i*16+j) < 0x20)
printf(" . "
else
printf(" %C ", ReadByte(Address+i*16+j));
}
printf("\n"
}
}int main()
{
unsigned long Address=0;
unsigned long tmp;
LoadFSLimit4G();
printf("====Designed By Southern. 1995.7.17====\n"
printf (" Now you can Access The Machine All 4G Memory.\n"
printf (" Input the Start Memory Physical to DUMP. \n"
printf (" Press D to Cuntinue DUMP, 0 to End & Quit, \n"
do
{
printf("-"
scanf("%IX", &tmp);
if(tmp==0x0d)
Address+=(20*16);
else
Address=tmp;
Dump4G(Address);
}while(Address != 0);
return 0;
}这段程序是说直接将内存空间扩大倒4G,可是我怎么编译通不过呢?编译器对汇编的编译需要什么配置啊EMS不怎么会用啊,您有源代码么?
|
|