⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boot.lst

📁 DOS SOURCE CODE,DOS-C started in 1988 as an experiment in writing device drivers in C for Microsof
💻 LST
📖 第 1 页 / 共 3 页
字号:
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 1
boot.ASM



      1				     ;
      2				     ; File:
      3				     ;				  boot.asm
      4				     ; Description:
      5				     ;				 DOS-C boot
      6				     ;
      7				     ;			     Copyright (c) 1997;
      8				     ;				 Svante	Frey
      9				     ;			     All Rights	Reserved
     10				     ;
     11				     ; This file is part of DOS-C.
     12				     ;
     13				     ; DOS-C is	free software; you can redistribute it and/or
     14				     ; modify it under the terms of the	GNU General Public License
     15				     ; as published by the Free	Software Foundation; either version
     16				     ; 2, or (at your option) any later	version.
     17				     ;
     18				     ; DOS-C is	distributed in the hope	that it	will be	useful,	but
     19				     ; WITHOUT ANY WARRANTY; without even the implied warranty of
     20				     ; MERCHANTABILITY or FITNESS FOR A	PARTICULAR PURPOSE.  See
     21				     ; the GNU General Public License for more details.
     22				     ;
     23				     ; You should have received	a copy of the GNU General Public
     24				     ; License along with DOS-C; see the file COPYING.	If not,
     25				     ; write to	the Free Software Foundation, 675 Mass Ave,
     26				     ; Cambridge, MA 02139, USA.
     27				     ;
     28				     ; $Logfile:   C:/dos-c/src/boot/boot.asv  $
     29				     ;
     30				     ; $Header:	  C:/dos-c/src/boot/boot.asv   1.5   10	Jan 1997  4:58:06   patv  $
     31				     ;
     32				     ; $Log:   C:/dos-c/src/boot/boot.asv  $
     33				     ;
     34				     ;		Rev 1.5	  10 Jan 1997  4:58:06	 patv
     35				     ;	     Corrected copyright
     36				     ;
     37				     ;		Rev 1.4	  10 Jan 1997  4:52:50	 patv
     38				     ;	     Re-written	to support C drive and eliminate restrictions on IPL.SYS
     39				     ;
     40				     ;		Rev 1.3	  29 Aug 1996 13:06:50	 patv
     41				     ;	     Bug fixes for v0.91b
     42				     ;
     43				     ;		Rev 1.2	  01 Sep 1995 17:56:44	 patv
     44				     ;	     First GPL release.
     45				     ;
     46				     ;		Rev 1.1	  30 Jul 1995 20:37:38	 patv
     47				     ;	     Initialized stack before use.
     48				     ;
     49				     ;		Rev 1.0	  02 Jul 1995 10:57:52	 patv
     50				     ;	     Initial revision.
     51				     ;
     52
     53
     54
     55
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 2
boot.ASM



     56	0000			     TEXT SEGMENT WORD PUBLIC 'TEXT'
     57				     ASSUME CS:TEXT, DS:TEXT
     58
     59	      =0000		     BASE	     equ     0
     60
     61
     62						     org     BASE
     63	0000  EB 3E 90		     Entry:	     jmp     real_start
     64
     65				     ;	     bp	is initialized to 7c00h
     66	      =	[bp+3]		     oem	     equ     [bp+3]
     67	      =	[bp+0bh]	     bytesPerSector  equ     [bp+0bh]
     68	      =	[bp+0dh]	     sectPerCluster  equ     [bp+0dh]
     69	      =	[bp+0eh]	     resSectors	     equ     [bp+0eh]
     70	      =	[bp+10h]	     nFats	     equ     [bp+10h]
     71	      =	[bp+11h]	     nRootDir	     equ     [bp+11h]
     72	      =	[bp+13h]	     nSectors	     equ     [bp+13h]
     73	      =	[bp+15h]	     MID	     equ     [bp+15h]
     74	      =	[bp+16h]	     sectPerFat	     equ     [bp+16h]
     75	      =	[bp+18h]	     sectPerTrack    equ     [bp+18h]
     76	      =	[bp+1ah]	     nHeads	     equ     [bp+1ah]
     77	      =	[bp+1ch]	     nHidden	     equ     [bp+1ch]
     78	      =	[bp+20h]	     nSectorHuge     equ     [bp+20h]
     79	      =	[bp+24h]	     drive	     equ     [bp+24h]
     80	      =	[bp+26h]	     extBoot	     equ     [bp+26h]
     81	      =	[bp+27h]	     volid	     equ     [bp+27h]
     82	      =	[bp+2bh]	     vollabel	     equ     [bp+2bh]
     83	      =	[bp+36h]	     filesys	     equ     [bp+36h]
     84
     85	      =2000		     LOADSEG	     equ     2000h
     86
     87	      =4000		     FATBUF	     equ     4000h	     ; offset of temporary buffer for FAT
     88									     ; chain
     89	      =0005		     RETRYCOUNT	     equ     5		     ; number of retries on disk errors
     90
     91				     ;	     Some extra	variables that are created on the stack	frame
     92
     93	      =	[bp-4]		     fat_start	     equ     [bp-4]	     ; first FAT sector
     94	      =	[bp-8]		     root_dir_start  equ     [bp-8]	     ; first root directory sector
     95	      =	[bp-12]		     data_start	     equ     [bp-12]	     ; first data sector
     96
     97
     98				     ;	     To	save space, functions that are just called once	are
     99				     ;	     implemented as macros instead. Four bytes are saved by
    100				     ;	     avoiding the call / ret instructions.
    101
    102
    103				     ;	     FINDFILE: Searches	for the	file in	the root directory.
    104				     ;
    105				     ;	     Returns:
    106				     ;
    107				     ;	     If	file not found:	     CF	set
    108				     ;
    109				     ;	     If	file found:	     CF	clear
    110				     ;				     AX	= first	cluster	of file
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 3
boot.ASM



    111
    112
    113				     FINDFILE	     MACRO
    114						     ; First, read the whole root directory
    115						     ; into the	temporary buffer.
    116
    117						     mov     ax, word ptr root_dir_start
    118						     mov     dx, word ptr root_dir_start+2
    119						     mov     di, nRootDir
    120						     xor     bx, bx
    121						     mov     es, tempbuf
    122						     call    readDisk
    123						     jc	     ffDone
    124
    125						     xor     di, di
    126
    127				     next_entry:     mov     cx, 11
    128						     mov     si, offset	filename+7c00h
    129						     push    di
    130						     repe    cmpsb
    131						     pop     di
    132						     mov     ax, es:[di][1ah]	 ; get cluster number from directory entry
    133						     clc
    134						     je	     ffDone
    135
    136						     add     di, 20h		 ; go to next directory	entry
    137						     cmp     byte ptr es:[di], 0     ; if the first byte of the	name is	0,
    138						     jnz     next_entry		     ; there is	no more	files in the directory
    139
    140						     stc
    141				     ffDone:
    142						     ENDM
    143
    144				     ;	     GETDRIVEPARMS:  Calculate start of	some disk areas.
    145
    146				     GETDRIVEPARMS   MACRO
    147						     mov     si, word ptr nHidden
    148						     mov     di, word ptr nHidden+2
    149						     add     si, word ptr resSectors
    150						     adc     di, 0		     ; DI:SI = first FAT sector
    151
    152						     mov     word ptr fat_start, si
    153						     mov     word ptr fat_start+2, di
    154
    155						     mov     al, nFats
    156						     xor     ah, ah
    157						     mul     word ptr sectPerFat     ; DX:AX = total number of FAT sectors
    158
    159						     add     si, ax
    160						     adc     di, dx		     ; DI:SI = first root directory sector
    161						     mov     word ptr root_dir_start, si
    162						     mov     word ptr root_dir_start+2,	di
    163
    164						     ; Calculate how many sectors the root directory occupies.
    165						     mov     bx, bytesPerSector
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 4
boot.ASM



    166						     mov     cl, 5		     ; divide BX by 32
    167						     shr     bx, cl		     ; BX = directory entries per sector
    168
    169						     mov     ax, nRootDir
    170						     xor     dx, dx
    171						     div     bx
    172
    173						     mov     nRootDir, ax	     ; AX = sectors per	root directory
    174
    175						     add     si, ax
    176						     adc     di, 0		     ; DI:SI = first data sector
    177
    178						     mov     data_start, si
    179						     mov     data_start+2, di
    180						     ENDM
    181
    182				     ;	     GETFATCHAIN:
    183				     ;
    184				     ;	     Reads the FAT chain and stores it in a temporary buffer in	the first
    185				     ;	     64	kb.  The FAT chain is stored an	array of 16-bit	cluster	numbers,
    186				     ;	     ending with 0.
    187				     ;
    188				     ;	     The file must fit in conventional memory, so it can't be larger than
    189				     ;	     640 kb. The sector	size must be at	least 512 bytes, so the	FAT chain
    190				     ;	     can't be larger than around 3 kb.
    191				     ;
    192				     ;	     Call with:	     AX	= first	cluster	in chain
    193				     ;
    194				     ;	     Returns:	     CF	clear on success, set on error
    195
    196				     GETFATCHAIN     MACRO
    197						     push    ax			     ; store first cluster number
    198
    199						     ; Load the	complete FAT into memory. The FAT can't	be larger
    200						     ; than 128	kb, so it should fit in	the temporary buffer.
    201
    202						     mov     es, tempbuf
    203						     xor     bx, bx
    204						     mov     di, sectPerFat
    205						     mov     ax, word ptr fat_start
    206						     mov     dx, word ptr fat_start+2
    207						     call    readDisk
    208						     pop     ax			     ; restore first cluster number
    209						     jc	     boot_error
    210
    211						     ; Set ES:DI to the	temporary storage for the FAT chain.
    212						     push    ds
    213						     push    es
    214						     pop     ds
    215						     pop     es
    216						     mov     di, FATBUF
    217
    218				     next_clust:     stosw			     ; store cluster number
    219						     mov     si, ax		     ; SI = cluster number
    220						     cmp     byte ptr extBoot, 29h
Turbo Assembler	 Version 3.1	    04/11/13 12:54:48	    Page 5
boot.ASM

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -