#include <stdio.h>
#include <stdlib.h>
#include <dos.h>
#include <string.h>
int check_for_ems(void)
{
union REGS inregs, outregs;
struct SREGS segs;
int major, minor; // DOS version
struct DeviceHeader {
struct DeviceHeader far *link;
unsigned attributes;
unsigned strategy_offset;
unsigned interrupt_offset;
char name_or_number_of_units[8];
} far *dev;
int i;
char driver_name[9];
// Get the DOS version
inregs.x.ax = 0x3001;
intdos (&inregs, &outregs);
major = outregs.h.al;
minor = outregs.h.ah;
if (major < 2)
return(0); // Requires DOS 2.0
else
{
// Get the list of lists
inregs.h.ah = 0x52;
intdosx (&inregs, &outregs, &segs);
if (major == 2)
dev = (struct DeviceHeader far *)
MK_FP(segs.es + 1, outregs.x.bx + 7);
else if ((major == 3) && (minor == 0))
dev = (struct DeviceHeader far *)
MK_FP(segs.es + 2, outregs.x.bx + 8);
else
dev = (struct DeviceHeader far *)
MK_FP(segs.es + 2, outregs.x.bx + 2);
while (FP_OFF(dev) != 0xFFFF)
{
if (dev->attributes & 0x8000)
{ // Character device
for (i = 0; i < 8; i++)
driver_name[i] = dev->name_or_number_of_units[i];
driver_name[8] = NULL;
}
if (! strcmp(driver_name, "EMMXXXX0"))
return(1); // Found driver
dev = dev->link;
}
}
return(0);
}
void main (void)
{
union REGS inregs, outregs;
struct SREGS segs;
unsigned handle;
unsigned page;
unsigned index, page_number;
unsigned page_frame_address;
char far *data;
if (check_for_ems())
{
inregs.h.ah = 0x40;
int86 (0x67, &inregs, &outregs);
// Make sure EMS is functional
if (outregs.h.ah == 0)
{
// Allocate a handle for 5 pages
inregs.h.ah = 0x43;
inregs.x.bx = 5;
int86 (0x67, &inregs, &outregs);
if (outregs.h.ah == 0)
{
handle = outregs.x.dx;
// Get the page frame address
inregs.h.ah = 0x41;
int86 (0x67, &inregs, &outregs);
if (outregs.h.ah == 0)
{
page_frame_address = outregs.x.bx;
// map the first 4 pages
for (page_number = 0; page_number < 4; page_number++)
{
inregs.h.ah = 0x44;
inregs.h.al = page_number; // Physical page
inregs.x.bx = page_number; // Logical page
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
if (outregs.h.ah != 0)
{
printf ("Error mapping pages %xH\n",
outregs.h.ah);
// Release the handle
inregs.h.ah = 0x45;
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
exit(0);
}
}
// Fill the first four pages
data = (char far *) MK_FP(page_frame_address, 0);
for (index = 0; index < 16384; index++)
data[index] = 'A';
for (index = 16384; index < 32768; index++)
data[index] = 'B';
for (index = 32768; index < 49152; index++)
data[index] = 'C';
for (index = 49152; index != 0; index++)
data[index] = 'D';
// Map logical page 4 into physical page 1
inregs.h.ah = 0x44;
inregs.h.al = 1; // Physical page
inregs.x.bx = 4; // Logical page
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
if (outregs.h.ah != 0)
{
printf ("Error mapping page %xH\n",
outregs.h.ah);
// Release the handle
inregs.h.ah = 0x45;
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
exit(0);
}
// Fill page 4 which resides in page 1
for (index = 16384; index < 32768; index++)
data[index] = 'E';
// Display the first 20 bytes of each page
printf ("Physical Page Zero\n");
for (index = 0; index < 20; index++)
printf ("%c ", data[index]);
printf ("\nPhysical Page One\n");
for (index = 16384; index < 16404; index++)
printf ("%c ", data[index]);
printf ("\nPhysical Page Two\n");
for (index = 32768; index < 32788; index++)
printf ("%c ", data[index]);
printf ("\nPhysical Page Three\n");
for (index = 49152; index < 49172; index++)
printf ("%c ", data[index]);
// Map logical page 1 into physical page 3
inregs.h.ah = 0x44;
inregs.h.al = 3; // Physical page
inregs.x.bx = 1; // Logical page
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
if (outregs.h.ah != 0)
{
printf ("Error mapping page %xH\n",
outregs.h.ah);
// Release the handle
inregs.h.ah = 0x45;
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
exit(0);
}
printf ("\nMapping logical page 1 to physical page 3");
printf ("\nPhysical Page Three\n");
for (index = 49152; index < 49162; index++)
printf ("%c ", data[index]);
}
else
printf ("Error getting base address %xH\n",
outregs.h.ah);
// Release the handle
inregs.h.ah = 0x45;
inregs.x.dx = handle;
int86 (0x67, &inregs, &outregs);
}
else
printf ("Error allocating 5 pages %xH\n",
outregs.h.ah);
}
else
printf ("EMM not functional\n");
}
else
printf ("EMS driver not present\n");
}
没有合适的资源?快使用搜索试试~ 我知道了~
c语言 900例原代码
共444个文件
c:432个
bak:11个
show_sum:1个
需积分: 0 1 下载量 196 浏览量
2008-10-03
14:50:43
上传
评论
收藏 137KB ZIP 举报
温馨提示
c语言的900个例子的原代码希望大家喜欢
资源推荐
资源详情
资源评论
收起资源包目录
c语言 900例原代码 (444个子文件)
BLD_1_10.BAK 2KB
DBL_1_10.BAK 875B
COUNTDOS.BAK 869B
FASTCALL.BAK 720B
1_10LIST.BAK 636B
ERSIMPLE.BAK 420B
CGETS.BAK 355B
CONFLICT.BAK 302B
COMMENT.BAK 247B
5_CONST.BAK 219B
CTRLBRK.BAK 191B
SHOWEMS.C 6KB
XMSDEMO.C 5KB
SYSTABLE.C 2KB
DELTREE.C 2KB
COPYDOS.C 2KB
SHOWCMOS.C 2KB
BLD_1_10.C 2KB
SORTLIST.C 1KB
ALLFILES.C 1KB
FILETABL.C 1KB
FILELIST.C 1KB
COUNTRY.C 1KB
REMOVE_7.C 1KB
SHOWEQUP.C 1KB
MORE.C 1024B
GET_PASS.C 1019B
MORE15.C 1009B
REMOVE5.C 998B
SPLIT.C 975B
LOWCOPY.C 965B
BSEARCH.C 965B
LFIND.C 963B
DTBITS.C 938B
BINARY.C 928B
DBL_1_10.C 883B
ALLTYPES.C 877B
COUNTDOS.C 866B
QUICK.C 863B
HEAPNODE.C 845B
JULY4_94.C 840B
KEYSTATE.C 840B
DOSCOPY.C 827B
QSORT.C 821B
MATHERR.C 803B
NO_REDIR.C 797B
UMASK.C 791B
ACCESS.C 765B
SHOW_3D.C 762B
SUM_2D.C 756B
SHELL.C 736B
FILLHEAP.C 736B
TIMER.C 732B
FILEDT.C 726B
FERROR.C 709B
PRINTCHK.C 709B
PUTWGETW.C 706B
FASTCALL.C 705B
PUTCH.C 705B
TELLATTR.C 702B
LSEARCH.C 699B
DUP.C 699B
FMALLOC.C 689B
CHGSTRUC.C 687B
FUNCTOVR.C 680B
CALLOC.C 680B
CHMEMBER.C 671B
FUNCT_2D.C 668B
MALLOC.C 668B
NOPRTSCR.C 667B
ADDVALUE.C 652B
STRUFUNC.C 649B
CHK_DISK.C 648B
TRYAUTO.C 644B
1_10LIST.C 643B
DTIN.C 642B
CPRINTF.C 640B
SHIFTEM.C 639B
SWT_MENU.C 637B
PUTS.C 630B
CPUTS.C 630B
DTINF.C 613B
FSCANF.C 594B
UNGETCH.C 591B
WAIT_YN.C 590B
SELECT.C 589B
DO_MENU.C 584B
AUTOINFO.C 573B
CONFCOPY.C 565B
STRFTIME.C 559B
STR_SORT.C 556B
LOCKING.C 551B
HEAPCHK.C 550B
SHOW_POS.C 546B
HANDLES.C 544B
SOPEN.C 543B
ALLOCA.C 542B
TELL.C 536B
BUBBLE.C 531B
WHICHDAY.C 531B
共 444 条
- 1
- 2
- 3
- 4
- 5
资源评论
FINDIE
- 粉丝: 0
- 资源: 10
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Linux常用命令及用法说明
- 基于Matlab的FFT频谱分析及IIR数字滤波器设计
- AutoCAD高压低压电气开关柜设备接线图图纸
- AutoCAD电气图纸建筑电气开关柜常用cad图纸
- 使用ASP.NET Core和Entity Framework Core来构建一个基本的进销存系统.rar
- 深度学习经典数据集+FER2013面部表情识别+附带使用方法的python代码
- Python中,要实现连接多个相机并识别多个二维码.rar
- 使用FFT算法对一个信号进行分析.rar
- 171cms游戏应用下载系统源码.zip
- 基于jsp+servlet+mysql蛋糕甜品店购物网站源码+数据库(期末大作业).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功