大雀软件园

首页 软件下载 安卓市场 苹果市场 电脑游戏 安卓游戏 文章资讯 驱动下载
技术开发 网页设计 图形图象 数据库 网络媒体 网络安全 站长CLUB 操作系统 媒体动画 安卓相关
当前位置: 首页 -> 技术开发 -> 程序开发 -> 读写CMOS内存

读写CMOS内存

时间: 2021-07-31 作者:daque

一、cmos外存消息详解 普遍的pc/at、286、386、486等微型计算机均配有cmos芯片,cmos&127;芯片包括了一个及时钟和64个字节的cmos外存。在cmos外存中,0-0dh为及时钟的相关消息,0e-&127;3fh包括计划机的硬件摆设消息,如惯例外存的巨细、扩充外存的巨细、&127;软盘的典型、恒定盘的典型及其物理参数、表露器的典型等,那些参数与计划机是否平常处事具备出色的联系,其余再有计划机的开机口令和其它扶助树立消息。表1列出了&127;cmos外存各字节的用处。 表1 cmos外存摆设消息的含意 地 址 功效 证明 0,1  秒,秒报告警方  2,3  分,分报告警方  4,5 时,时报告警方  6 礼拜几  7,8,9 日,月,年  a 状况存放器a  b 状况存放器b  c 状况存放器c  d 状况存放器d 0=干电池作废,80=干电池灵验 e 确诊状况  f 关灯状况 由上电确诊设置 10 软驱 高4位为a驱,低4位为b驱,0=无, 1=360kb, 2=1.2kb, 4=1.44kb, 6=720kb 11 保持  12 恒定盘 高4位为c驱,低4位为d驱,0=无,f=用户设置盘, 其它为体例设置盘 13 保持  14 摆设状况 标记启动器数、表露器典型、有多数学处置器等 15-16 外存 以kb计的惯例外存数,100h=256kb,200h=512kb, 280h=640kb 17-18 扩充外存 以kb计的扩充外存数,200h=512kb,400h=1024kb等 19 c盘典型数 按照简直硬盘典型而定 1a d盘典型数 按照简直硬盘典型而定 1b-1c 保持  1d-1e c盘柱体数 1d-2ch惟有当硬盘为用户自设置典型时起效率 1f c盘面数  20-21 c盘wp  22-23 c盘lz  24 c盘每柱扇区  25-26 d盘柱体数  27 d盘面数  28-29 d盘wp  2a-2b d盘lz  2c d盘每柱扇区  2d 保持  2e-2f 校验和 为10-2dh共30个字节的和数,2eh为上位,2fh为低位 30-31 扩充外存  32 日子的世纪数 bcd码的世纪值,如1995年的世纪数为19 33 标记消息  34-3f 保持                  *地方栏均为16进制表白 二、读写CMOS内存的本领 cmos外存的地方口和数据口的口地方辨别为70h和71h。在对cmos外存举行写操纵时,开始将要写入的cmos外存的地方送给口地方70h,&127;再将要写入的数据送口地方71h。在对cmos外存举行读操纵时,开始将要读出的cmos外存的地方送给口地方70h,再从口地方71h读出数据到al存放器。 三、步调安排与运用 为了简单体例消息丧失后cmos消息的回复,作家用borland pascal&127;安排了一个cmos.pas的步调,它不妨将cmos外存中的消息径直写入文献,也不妨把文献中的消息写入cmos外存,同声不妨对cmos外存中的消息举行编纂窜改,并从新写回cmos外存。它不只处置了没有setup步调的计划机在加电时不许树立cmos外存的题目,同声处置了cmos消息的生存和回复题目,是宏大计划机用户的一个好帮忙。 该步调的运用很大略,在dos提醒符下打cmos,即表露该步调的运用本领,&127;简直运用本领是: cmos [/电门] 电门有3个: r --- 读取cmos外存消息,并将其惠存cmos.dat的文献,共占64个字节。 w --- 从cmos.dat中读守信息,并将其写入cmos外存。&127;提防如许写入的cmos消息,当时间和日子是不精确的,写完之后该当用dos吩咐date和time&127;树立精确的日子和功夫。 m --- 从cmos中读取暂时消息,举行窜改,而后将其写入cmos外存和cmos.dat的文献。 四、步调清单 因为篇幅的控制,步调中略去了用turbo &127;vision&127;编写的步调界面局部。 program cmos; type tcmostype = record     seconds : byte;     secondalarm : byte;     minutes : byte;     minutealarm : byte;     hours : byte;     houralarm : byte;     dayofweek : byte;     dayofmonth : byte;     month : byte;     year : byte;     statusrega : byte;     statusregb : byte;     statusregc : byte;     statusregd : byte;     diagstatus : byte;     shutdownstatus : byte;     floppydrive : byte;     reserved1 : byte;     fixeddrive : byte;     reserved2 : byte;     equipment : byte;     ram : word;     xms : word;     fixeddrivetype1 : byte;     fixeddrivetype2 : byte;     reserved3 : word;     cylinder1 : word;     head1 : byte;     wp1 : word;     lz1 : word;     sector1 : byte;     cylinder2 : word;     head2 : byte;     wp2 : word;     lz2 : word;     sector2 : byte;     sys : byte;     checksum : word;     xms1 : word;     datecentury : byte;     infoflags : byte;     reserved4: array[1..12] of byte; end; tbyte64 = array[1..64] of byte; tcmos = object     cmosrec : tcmostype;     procedure readcmos;     procedure writecmos;     procedure displaycmos;     procedure modifycmos;     procedure readfile;     procedure writefile; end; procedure tcmos.readfile; var     f1 : file;     data : tbyte64 absolute cmosrec;     ch : char; begin     write('please input the drive name (a/b/c/d): ');     readln(ch);     assign(f1,ch+':\cmos.dat');     reset(f1,1);     blockread(f1,data,sizeof(data));     close(f1); end; procedure tcmos.writefile; var     f1:file;     data : tbyte64 absolute cmosrec;     ch : char; begin     write('please input the drive name (a/b/c/d): ');     readln(ch);     assign(f1,ch+':\cmos.dat');     rewrite(f1,1);     blockwrite(f1,data,sizeof(data));     close(f1); end; procedure tcmos.readcmos; begin asm les di,self add di,cmosrec mov cx,40h mov ah,0h mov bx,0 @1: mov dx,70h mov al,ah out dx,al inc dx in al,dx mov byte ptr es:[di+bx],al inc ah inc bx dec cx jnz @1 end; end; procedure tcmos.writecmos; begin asm les di,self add di,cmosrec mov cx,40h mov ah,0h mov bx,0 @1: mov dx,70h mov al,ah out dx,al mov al,byte ptr es:[di+bx] inc dx out dx,al inc ah inc bx dec cx jnz @1 end; end; procedure tcmos.displaycmos; var hd1,hd2,fd1,fd2 : byte; begin writeln(^j^m'cmos ram information:'); writeln('date(mm-dd-yy): ',cmosrec.month shr 4,cmosrec.month and $f, '-',cmosrec.dayofmonth shr 4,cmosrec.dayofmonth and $f, '-',cmosrec.year shr 4,cmosrec.year and $f); writeln('time(hh:mm:ss): ',cmosrec.hours shr 4,cmosrec.hours and $f, ':',cmosrec.minutes shr 4,cmosrec.minutes and $f, ':',cmosrec.seconds shr 4,cmosrec.seconds and $f); writeln('conventional memory: ',cmosrec.ram,'kb'); writeln('extended memory: ',cmosrec.xms,'kb'); hd2 := cmosrec.fixeddrive and $f; hd1 := cmosrec.fixeddrive shr 4; if (hd1 <> 0) then begin writeln('fixed drive 1: ',cmosrec.fixeddrivetype1); writeln(' cylinder : ',cmosrec.cylinder1); writeln(' head : ',cmosrec.head1); writeln(' sector: ',cmosrec.sector1); writeln(' lz: ',cmosrec.lz1); writeln(' wp: ',cmosrec.wp1); end; if (hd2 <> 0) then begin writeln('fixed drive 2: ',cmosrec.fixeddrivetype2); writeln(' cylinder : ',cmosrec.cylinder2); writeln(' head : ',cmosrec.head2); writeln(' sector: ',cmosrec.sector2); writeln(' lz: ',cmosrec.lz2); writeln(' wp: ',cmosrec.wp2); end; fd2 := cmosrec.floppydrive and $f; fd1 := cmosrec.floppydrive shr 4; if (fd1 <> 0) then begin write('floppy drive 1 : '); case fd1 of 1 : writeln('360kb 5.25'''); 2 : writeln('1.2mb 5.25'''); 4 : writeln('1.44mb 3.5'''); 6 : writeln('720kb 3.5'''); end; end ; if (fd2 <> 0) then begin write('floppy drive 2 : '); case fd2 of 1 : writeln('360kb 5.25'''); 2 : writeln('1.2mb 5.25'''); 4 : writeln('1.44mb 3.5'''); 6 : writeln('720kb 3.5'''); end; end; end; procedure tcmos.modifycmos; var hd1,hd2,fd1,fd2 : byte; data : tbyte64 absolute cmosrec; i : word; begin writeln('please input correct cmos information !'); write('conventional memory (',cmosrec.ram,'kb): ');readln(cmosrec.ram); write('extended memory (',cmosrec.xms,'kb): ');readln(cmosrec.xms); write('type of fixed disk 1: (',cmosrec.fixeddrivetype1,'): ');readln(cmosre c.fixeddrivetype1); write(' cylinder (',cmosrec.cylinder1,'):'); readln(cmosrec.cylinder1); write(' head (',cmosrec.head1,'): ');readln(cmosrec.head1); write(' sector (',cmosrec.sector1,'): ');readln(cmosrec.sector1); write(' lz (',cmosrec.lz1,'): ');readln(cmosrec.lz1); write(' wp (',cmosrec.wp1,'): ');readln(cmosrec.wp1); write('type of fixed disk 2: (',cmosrec.fixeddrivetype2,'): ');readln(cmosre c.fixeddrivetype2); write(' cylinder (',cmosrec.cylinder2,'):'); readln(cmosrec.cylinder2); write(' head (',cmosrec.head2,'): ');readln(cmosrec.head2); write(' sector (',cmosrec.sector2,'): ');readln(cmosrec.sector2); write(' lz (',cmosrec.lz2,'): ');readln(cmosrec.lz2); write(' wp (',cmosrec.wp2,'): ');readln(cmosrec.wp2); hd1 := 0; hd2 :=0; if (cmosrec.fixeddrivetype1>46) then hd1 := $f; if (cmosrec.fixeddrivetype2>46) then hd2 := $f; cmosrec.fixeddrive := hd1 shl 4 + hd2; fd2 := cmosrec.floppydrive and $f; fd1 := cmosrec.floppydrive shr 4; write('floppy drive 1 ('); case fd1 of 1 : write('360kb 5.25''): '); 2 : write('1.2mb 5.25''): '); 4 : write('1.44mb 3.5''): '); 6 : write('720kb 3.5''): '); end; readln(fd1); write('floppy drive 2 ('); case fd2 of 1 : write('360kb 5.25''): '); 2 : write('1.2mb 5.25''): '); 4 : write('1.44mb 3.5''): '); 6 : write('720kb 3.5''): '); end; readln(fd2); cmosrec.floppydrive := fd1 shl 4 + fd2; cmosrec.checksum := 0; for i := 17 to 46 do inc(cmosrec.checksum,data[i]); i := cmosrec.checksum; data[47] := hi(i); data[48] := lo(i); end; procedure help; begin writeln('syntex:'+^j^m+ ' cmos /r --- read information from cmos ram '+^j^m+ ' and write it to cmos.dat file '+^j^m+ ' cmos /w --- read configuration information from cmos.dat '+^j^m+ ' and write it to cmos ram'); writeln(' cmos /m --- modify cmos information and save it'^j^m+ ' floppy drive type:'+^j^m+ ' 1 : 360kb 5.25'''+^j^m+ ' 2 : 1.2mb 5.25'''+^j^m+ ' 4 : 1.44mb 3.5'''+^j^m+ ' 6 : 720kb 3.5'''); end; var ch : char; temp : string; icmos : tcmos; begin writeln('cmos proctector 1.00, copyright (c) 1995 dong zhanshan'); if paramcount = 1 then begin temp := paramstr(1); ch := upcase(temp[2]); case ch of 'm' : begin icmos.readcmos; icmos.modifycmos; icmos.displaycmos; icmos.writefile; icmos.writecmos; end; 'r' : begin icmos.readcmos; icmos.displaycmos; icmos.writefile; end; 'w' : begin icmos.readfile; icmos.displaycmos; icmos.writecmos; end; else help; end; end else help; end. 

热门阅览

最新排行

Copyright © 2019-2021 大雀软件园(www.daque.cn) All Rights Reserved.