|
如何在C程序使用中国科学院43分机
我们可以要求延长43*功能与同一丙职能(int86(),int86x()等), 我们用的是较早的章节. 让我们学习它的一个例子.
以下例子给出的三个重点功能(目前延期检查,并延伸扩展阅读书写). 但是我们不会使用写功能扩展本章.
如果计画一次检查,如果不支持或延延为中国科学院现有43、 这句绝对界0(从而器)的磁盘. 在节目进行编码的方式如下:
/* 节目获得超出8.46绿化部门利用中国科学院的BIOS分机13 */
#include<stdio.h>
#include<dos.h>
/* 高度的数据类型的标识符 */
typedef unsigned char Byte;
typedef unsigned int Word;
typedef unsigned long DWord;
/* disk_packet结构装货直:四、指挥处死 */
struct disk_packet
{
Byte size_pack; // 大小必须是16或16+包
Byte reserved1; // 预留
Byte no_of_blocks;// 若干块转让
Byte reserved2; // 预留
/* 演讲部分:抵消格式 */
Word offset; //抵销处理
Word segment; //部分地址
/* 支持容量磁盘甚至1152921504.607绿化 */
DWord lba1;
DWord lba2;
}disk_pack;
/* 功能检查各分机支持 */
void check_ext_present()
{
union REGS inregs, outregs; /* 投入产出登记 */
inregs.h.ah=0x41; /* 扩建现有功能检查 */
inregs.x.bx=0x55AA;
inregs.h.dl=0x80; /* 硬盘驱动无首 */
int86(0x13,&inregs,&outregs); /*电话打断 */
if(outregs.x.cflag)
{
/*不支持扩展 */
printf("\nBios extension not supported");
exit(1);
}
if(outregs.x.bx==0xAA55)
if(outregs.x.cx & 0x1)
/* 目前扩建 */
printf("\nExtended I/O supported");
}
/* 职能部门经过 */
void read_sectors(void *buffer)
{
union REGS inregs, outregs; /* 投入产出登记 */
struct SREGS segregs; // 部分登记
disk_pack.size_pack=16; // 大小为16集
disk_pack.no_of_blocks=1; // 1块
disk_pack.reserved1=0; // 保留字
disk_pack.reserved2=0; // 保留字
disk_pack.segment=FP_SEG(buffer);// 部分缓冲
disk_pack.offset=FP_OFF(buffer); // 缓冲抵消
/* 请求膜硬盘1 */
/* 经过界绝对0 */
disk_pack.lba1=0; /* 财产的工作属于职业地址,包含32位元首 */
/* 我们通常需要(开车<2.1酯)仅此一套 */
disk_pack.lba2=0; // 去年32比特地址
inregs.h.ah=0x42; // 阅读功能
inregs.h.dl=0x80; // 硬盘驱动人数首次fp_offinregs.x.si=(&disk_pack); /*作直:四点disk_pack */
segregs.ds = FP_SEG(&disk_pack);
/* 电话打断*/
int86x(0x13,&inregs,&outregs,&segregs);
if(outregs.x.cflag)
printf("\n\nError %d\n",outregs.h.ah);
else
printf("\n\nI hope Everything is all Right");
}
//// 职能部门写信 \\\\
void write_sector()
{
/* 会写read_sectors功能一样,除了一些职能、 0x43将在这个功能. 我们会在下一章节讨论延长书写功能.
使用这项功能之前请查证究竟要怎么办. 你应该有正确的认识,你该怎么办. 使用此功能不了解或不小心可能会破坏你的数据. */
}
/// 主要职能 \\\\
void main()
{
int i=0;
/* 膜生物反应器进行缓冲 */
Byte mbr[512];
clrscr();
/* 目前支票的BIOS延伸 */
check_ext_present();
/* 经过机构 */
read_sectors(&mbr);
printf("\n\n Data of MBR \n");
printf("▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀\n\n\n");
while(i++<512)
{
/* 展示缓冲膜 */
printf("%c",mbr[i]);
}
}
评论编码方案
typedef高度等数据类型的标识符的字节,typedef签名烧焦;字节的数据类型标识符高度烧焦.同样是分配到中国科学院和标识字dword交由长.
disk_packet装货的结构是直:硅和指挥(如延伸阅读 书写或延长核查等)处死. IBM公司职能见/中国科学院43余支(适量职能作用L.17-L.21)鉴于前.
check_ext_present()的功能,如果检查分机复本/支持与否.所谓功能与粉=55aah(inregs.x.bx=0x55aa;) 如果延支持粉定aa55h登记.(见功能适量前)
read_sectors职能部门绝对是用来阅读的磁盘,指定disk_pack.lba1. 我们对这一计划给予disk_pack.lba1=0, 因此我们将予以绝对界0(注见下文)从而将经过膜的圆盘.
write_sector的功能也是一样的功能,将写在read_sectors一样但选择不同的功能. 我们将利用它在下一章节.
Note:
我们经过磁盘在以下两个方面:
- 相关部门经过(或写)
- 绝对界经过(或写)
在相对界看我们看过盘行业按照货物(缸、 头部和部门)的磁盘几何.在经过相对界膜的盘(第一部分盘)是汽缸0 0、1头部门.
在绝对读磁盘行业 我们不必指明或汽缸头号码的计划. 从行业绝对绝对界0票.
因此如果要经过反应器的磁盘(第一部分盘) 我们要看到绝对界0. 它的BIOS把工作的绝对数量相应部门缸、界头数.
正如在绝对界读(或写) 我们只计算绝对环路内的业务部门,如阅读或书写整盘、 而在相对界案阅读(或写作) 我们要办的三环路时间计算货物因此绝对界读/写是相对较界读/writing.
举例来说,如果有硬盘的16头(方),并与63个行业的12瓶、 提交给下面 显示差异均读程序和方法,从而显示出绝对的行业采取的做法,可能使我们的节目时间(如整个磁盘读/写或整盘擦节目等)办得快:
Relative Sectors Reading |
Absolute Sector reading |
Cylinder =0, Head =0, Sector = 1 |
Absolute Sector = 0 |
Cylinder =0, Head =0, Sector = 2 |
Absolute Sector = 1 |
Cylinder =0, Head =0, Sector = 3 |
Absolute Sector = 2 |
.
.
.
. |
.
.
.
. |
Cylinder =0, Head =0, Sector = 62 |
Absolute Sector = 61 |
Cylinder =0, Head =0, Sector = 63 |
Absolute Sector = 62 |
Cylinder =0, Head =1, Sector = 1 |
Absolute Sector = 63 |
Cylinder =0, Head =1, Sector = 2 |
Absolute Sector = 64 |
Cylinder =0, Head =1, Sector = 3 |
Absolute Sector = 65 |
Cylinder =0, Head =1, Sector = 4 |
Absolute Sector = 66 |
.
.
.
. |
.
.
.
. |
Cylinder =0, Head =1, Sector = 63 |
Absolute Sector = 125 |
Cylinder =0, Head =2, Sector = 1 |
Absolute Sector = 126 |
Cylinder =0, Head =2, Sector = 2 |
Absolute Sector = 127 |
Cylinder =0, Head =2, Sector = 3 |
Absolute Sector = 128 |
.
.
.
. |
.
.
.
. |
Cylinder =0, Head =15, Sector = 63 |
Absolute Sector = 1007 |
Cylinder =1, Head =0, Sector = 1 |
Absolute Sector = 1008 |
Cylinder =1, Head =0, Sector = 2 |
Absolute Sector = 1009 |
Cylinder =1, Head =0, Sector = 3 |
Absolute Sector = 1010 |
.
.
.
. |
.
.
.
. |
Cylinder =1, Head =0, Sector = 63 |
Absolute Sector = 1070 |
Cylinder =1, Head =1, Sector = 1 |
Absolute Sector = 1071 |
Cylinder =1, Head =1, Sector = 2 |
Absolute Sector = 1072 |
Cylinder =1, Head =1, Sector = 3 |
Absolute Sector = 1073 |
.
.
.
. |
.
.
.
. |
Cylinder =1, Head =15, Sector = 63 |
Absolute Sector = 2015 |
Cylinder =2, Head =0, Sector = 1 |
Absolute Sector = 2016 |
Cylinder =2, Head =0, Sector = 2 |
Absolute Sector = 2017 |
Cylinder =2, Head =0, Sector = 3 |
Absolute Sector = 2018 |
.
.
.
. |
.
.
.
. |
Cylinder =11, Head =15, Sector = 60 |
Absolute Sector = 12092 |
Cylinder =11, Head =15, Sector = 61 |
Absolute Sector = 12093 |
Cylinder =11, Head =15, Sector = 62 |
Absolute Sector = 12094 |
Cylinder =11, Head =15, Sector = 63 |
Absolute Sector = 12095 |
资料划分表膜,是膜生物反应器的分析显示有磁盘工具,已列举如下:
在上述资料,供相关部门号码间隔两起,分别是63、11277630、 而据计算,不受间隔及次数方面,提供磁盘.
|
|