你好,欢迎来到电脑编程技巧与维护杂志社! 杂志社简介广告服务读者反馈编程社区  
合订本订阅
 
 
您的位置:杂志经典 / 编程语言
操作系统以外的硬盘空间(下)
 

 

savembr:

;    -----  Debug instrution ------

;         mov  ds,cs:dataseg1

;         lea  dx,debug

;   call disp1

;   mov  ah,07h

;   int  21h

;   cli

;    ------------------------------

;         sub  ax,ax

;        pop  ds             ;ds=_data

;        push ds

;        pop  es             ;es=_data

         mov  ax,0201h

;   mov  bx,offset buffer

         lea  bx,buffer      ;es:bx=_data:buffer ,es=seg _data

     mov  cx,0001h

     mov  dx,0080h

     int  13h       

;   push bx

     jb   harddiskreaderr

;   mov  ax,_data

;   mov  ds,ax

;   push bx   

         xor  bx,bx

     mov  dx,offset filename

     mov  cx,0

     mov  ah,3ch

     int  21h

     jc   filecreaterr

     mov  bx,ax

     mov  dx,offset buffer

;   pop  dx

         mov  cx,200h

     mov  ah,40h

     int  21h

     jc   filewriteerr

     mov  ah,3eh

     int  21h

     jmp  filewriteok

   

filecreaterr:

         lea  dx,filecreaterrmsg

     jmp  disp

;   call disp

;   call rettodos

filewriteerr:

         lea  dx,filewriteerrmsg

;   call disp

;   call rettodos

         jmp  disp

harddiskreaderr:

         lea  dx,hdreaderrmsg

     jmp  disp

     

;   call disp

;   call rettodos

filewriteok:

         lea  dx,filewriteokmsg

     jmp  disp

;   call disp

;   call rettodos

 

writembr:

;        pop  ds       ;ds=_data

;        push ds      

;        pop  es       ;es=_data

         lea  dx,filename

     mov  ax,3d00h

     mov  cx,0

     int  21h

     jc   fileopenerr

     mov  bx,ax

     mov  cx,200h

     lea  dx,buffer

     push dx

     mov  ah,3fh

     int  21h

     jc   filereaderr

     mov  ah,3eh

     int  21h

     pop  bx

     mov  ax,0301h

     mov  cx,0001h

     mov  dx,0080h

     int  13h

     jb   hdwriteerr

     jnb  mbrwriteok

;   jmp  reboot

filereaderr:

         lea  dx,filereaderrmsg

     jmp  disp

;   call disp

;   call rettodos

fileopenerr:

         lea  dx,fileopenerrmsg

     jmp  disp

;   call disp

;   call rettodos

hdwriteerr:

         lea  dx,hdwriteerrmsg

     jmp  disp

;   call disp

;   call rettodos

hdreaderr:

         lea  dx,hdreaderrmsg

     jmp  disp

;   call disp

;   call rettodos

mbrwriteok:

         lea  dx,mbrwriteokmsg

     call disp1

;   jmp  reboot

     call rettodos

savedcmosdatatohd:

;         mov  ds,cs:[dataseg1]       ;pop ds    ;ds=_data seg

;   push ds

;   pop  es            ;es=_data

         mov  bx,offset buffer

     cld

     xor  cx,cx

     push cx

     pop  ax

     mov  cx,70h

     mov  al,10h

     push bx              ;mistake goes here,it must be push

     cld

cmosdatareadloop:

         out  70h,al

     push ax

     in   al,71h

     mov  ds:[bx],al

     pop  ax

     inc  bx

     inc  al

     loop cmosdatareadloop

     std

     pop  bx         ;lea bx,buffer

     mov  ax,0301h

;   mov  bx,offset buffer

         mov  cx,1ch         ;modify the number

     mov  dx,0080h

     int  13h

     jb   hdwriteerr

;   jb   cmossavetohdok

 

cmossavetohdok:

         lea  dx,cmossavedtohdokmsg

     jmp  disp

;   call disp

;   call rettodos

 

cmoscheckedmbrld:

         mov  ax,0201h

     mov  bx,offset buffer

     mov  cx,0001h

     mov  dx,0080h

     int  13h

     jb   hdreaderr

     cld

     mov  si,offset buffer+01beh

     mov  di,offset sector+01beh

     mov  cx,40h

     repne movsb

;   std

     mov  ax,0301h

     mov  bx,offset buffer

     mov  cx,19

     mov  dx,0080h

     int  13h

     jb   hdwriteerr

     lea  dx,mbrbkokmsg

     call disp1

     mov  ax,0301h

     mov  bx,offset sector

     mov  cx,0001h

     mov  dx,0080h

     int  13h    

     jb   hdwriteerr

     lea  dx,cmoscheckedmbrldokmsg

     call disp1

;   jmp  reboot

     jmp  rettodos

error:

;        pop  ds               ;ds=_data

         lea  dx,wrongparamsg

     call disp1

     mov  ax,0200h

;         mov  si,81h

;   inc  si

;         pop  ds           ;ds=psp

         mov  ds,cs:pspseg

;         mov  si,81h

         pop  si

     dec  si

prnwrongparameter:

;        mov  dl,ds:[si]

;        cmp  dl,0dh

;        jz   retdos

;        mov  ah,02h

;        int  21h

;        inc  si

;        loop prnwrongparameter

     lodsb

     cmp  al,0dh

     jz   retdos

     mov  dl,al

;   mov  ah,02h

     int  21h

;   inc  si

     loop prnwrongparameter

;   call disp

retdos:

         mov  dl,'"'

     int  21h

     mov  dl,'!'

     int  21h

     jmp rettodos

reboot:

;         lea  bx,res

     mov  word ptr [bx],1234h

         lea  bx,dat

     call dword ptr [bx]

disp:

         mov  ah,09h

     int  21h

rettodos:  

     mov  ah,4ch

     int  21h

main endp

disp1 proc near

         mov  ah,09h

     int  21h

     ret

disp1 endp

;rettodos proc near

 ;        mov  ah,4ch

;   int  21h

;rettodos endp

 dataseg1 dw ?      

 pspseg dw ?

end start

 

1.   数据转换程序

/* 把二进制文件转换成汇编语言的数据文件格式 */

/* bintodat *.bin *.out */

 

 

#include <stdio.h>

#include <stdlib.h>

long filesize(FILE *stream)

{

 long curpos,length;

 curpos=ftell(stream);

 fseek(stream,0L,SEEK_END);

 length=ftell(stream);

 fseek(stream,curpos,SEEK_SET);

 return length;

}

int main(int argc,char * *argv)

{

 FILE *fp1,*fp2;

 long fsize;

 unsigned i;

 unsigned char tmp;

 if(argc<2)

 {

  printf("Usage:BINTODAT [input] [output]");

  exit(1);

 }

 fp1=fopen(argv[1],"rb");

  if(fp1==NULL)

  {printf("Open file %s error ",argv[1]);

   exit(0);

  }

 fp2=fopen(argv[2],"wt");

 fsize=filesize(fp1);

 fprintf(fp2,"\n\tdb  ");

 for(i=0;i<fsize;i++)

 {

  tmp=fgetc(fp1);

  if(tmp<0xa0)

   fprintf(fp2,"%02Xh,",tmp);

  else

   fprintf(fp2,"%03Xh,",tmp);

  if((i+1)%12==0)fprintf(fp2,"\n\tdb  ");

 }

 printf("\nProcess O.K.");

 return 0;

}

  推荐精品文章

·2024年12月目录 
·2024年11月目录 
·2024年10月目录 
·2024年9月目录 
·2024年8月目录 
·2024年7月目录 
·2024年6月目录 
·2024年5月目录 
·2024年4月目录 
·2024年3月目录 
·2024年2月目录 
·2024年1月目录
·2023年12月目录
·2023年11月目录

  联系方式
TEL:010-82561037
Fax: 010-82561614
QQ: 100164630
Mail:gaojian@comprg.com.cn

  友情链接
 
Copyright 2001-2010, www.comprg.com.cn, All Rights Reserved
京ICP备14022230号-1,电话/传真:010-82561037 82561614 ,Mail:gaojian@comprg.com.cn
地址:北京市海淀区远大路20号宝蓝大厦E座704,邮编:100089