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

📄 mbr.lst

📁 Windows上的精简Linux系统
💻 LST
📖 第 1 页 / 共 2 页
字号:
     1                                  ; -----------------------------------------------------------------------     2                                  ;        3                                  ;   Copyright 2003-2004 H. Peter Anvin - All Rights Reserved     4                                  ;     5                                  ;   Permission is hereby granted, free of charge, to any person     6                                  ;   obtaining a copy of this software and associated documentation     7                                  ;   files (the "Software"), to deal in the Software without     8                                  ;   restriction, including without limitation the rights to use,     9                                  ;   copy, modify, merge, publish, distribute, sublicense, and/or    10                                  ;   sell copies of the Software, and to permit persons to whom    11                                  ;   the Software is furnished to do so, subject to the following    12                                  ;   conditions:    13                                  ;       14                                  ;   The above copyright notice and this permission notice shall    15                                  ;   be included in all copies or substantial portions of the Software.    16                                  ;       17                                  ;   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,    18                                  ;   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES    19                                  ;   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND    20                                  ;   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT    21                                  ;   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,    22                                  ;   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING    23                                  ;   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR    24                                  ;   OTHER DEALINGS IN THE SOFTWARE.    25                                  ;    26                                  ; -----------------------------------------------------------------------    27                                      28                                  ;    29                                  ; mbr.asm    30                                  ;    31                                  ; Simple Master Boot Record, including support for EBIOS extensions.    32                                  ;     33                                  ; The MBR lives in front of the boot sector, and is responsible for    34                                  ; loading the boot sector of the active partition.  The EBIOS support    35                                  ; is needed if the active partition starts beyond cylinder 1024.    36                                  ;     37                                  ; This MBR determines all geometry info at runtime.  It uses only the    38                                  ; linear block field in the partition table.  It does, however, pass    39                                  ; the partition table information unchanged to the target OS.    40                                  ;    41                                  ; This MBR should be "8086-clean", i.e. not require a 386.    42                                  ;    43                                      44                                  %include "bios.inc"    45                              <1> ;; $Id: bios.inc,v 1.2 2004/01/29 06:54:51 hpa Exp $    46                              <1> ;; -----------------------------------------------------------------------    47                              <1> ;;       48                              <1> ;;   Copyright 1994-2004 H. Peter Anvin - All Rights Reserved    49                              <1> ;;    50                              <1> ;;   This program is free software; you can redistribute it and/or modify    51                              <1> ;;   it under the terms of the GNU General Public License as published by    52                              <1> ;;   the Free Software Foundation, Inc., 53 Temple Place Ste 330,    53                              <1> ;;   Bostom MA 02111-1307, USA; either version 2 of the License, or    54                              <1> ;;   (at your option) any later version; incorporated herein by reference.    55                              <1> ;;    56                              <1> ;; -----------------------------------------------------------------------    57                              <1>     58                              <1> ;;    59                              <1> ;; bios.inc    60                              <1> ;;     61                              <1> ;; Header file for the BIOS data structures etc.    62                              <1> ;;    63                              <1>     64                              <1> %ifndef _BIOS_INC    65                              <1> %define _BIOS_INC    66                              <1>     67                              <1> 		absolute 4*1Eh		; In the interrupt table    68                              <1> fdctab		equ $    69 00000078 <res 00000002>      <1> fdctab1		resw 1    70 0000007A <res 00000002>      <1> fdctab2		resw 1    71                              <1> 		absolute 0400h    72 00000400 <res 00000008>      <1> serial_base	resw 4			; Base addresses for 4 serial ports    73                              <1> 		absolute 0413h    74 00000413 <res 00000002>      <1> BIOS_fbm	resw 1			; Free Base Memory (kilobytes)    75                              <1> 		absolute 0462h    76 00000462 <res 00000001>      <1> BIOS_page	resb 1			; Current video page    77                              <1> 		absolute 046Ch    78 0000046C <res 00000002>      <1> BIOS_timer	resw 1			; Timer ticks    79                              <1> 		absolute 0472h    80 00000472 <res 00000002>      <1> BIOS_magic	resw 1			; BIOS reset magic    81                              <1>                 absolute 0484h    82 00000484 <res 00000001>      <1> BIOS_vidrows    resb 1			; Number of screen rows    83                              <1>     84                              <1> %endif ; _BIOS_INC    85                                  	    86                                  ;    87                                  ; Note: The MBR is actually loaded at 0:7C00h, but we quickly move it down to    88                                  ; 0600h.    89                                  ;    90                                  		section .text    91                                  		cpu 8086    92                                  		org 0600h    93                                      94 00000000 FA                      _start:		cli    95 00000001 31C0                    		xor ax,ax    96 00000003 8ED8                    		mov ds,ax    97 00000005 8EC0                    		mov es,ax    98 00000007 8ED0                    		mov ss,ax    99 00000009 BC007C                  		mov sp,7C00h   100 0000000C FB                      		sti   101 0000000D FC                      		cld   102 0000000E 89E6                    		mov si,sp		; Start address   103 00000010 BF0006                  		mov di,0600h		; Destination address   104 00000013 B90001                  		mov cx,512/2   105 00000016 F3A5                    		rep movsw   106                                     107                                  ;   108                                  ; Now, jump to the copy at 0600h so we can load the boot sector at 7C00h.   109                                  ; Since some BIOSes seem to think 0000:7C00h and 07C0:0000h are the same   110                                  ; thing, use a far jump to canonicalize the address.  This also makes   111                                  ; sure that it is a code speculation barrier.   112                                  ;   113                                     114 00000018 EA[1D00]0000            		jmp 0:next		; Jump to copy at 0600h   115                                  				   116                                  next:   117 0000001D 88160008                		mov [DriveNo], dl		; Drive number stored in DL   118                                  ;   119                                  ; Check for CHS parameters.  This doesn't work on floppy disks,   120                                  ; but for an MBR we don't care.   121                                  ;   122 00000021 B408                    		mov ah,08h			; Get drive parameters   123 00000023 CD13                    		int 13h   124 00000025 31C0                    		xor ax,ax   125 00000027 88F0                    		mov al,dh   126 00000029 40                      		inc ax				; From 0-based to count   127 0000002A A3[F000]                		mov [Heads],ax   128 0000002D 80E13F                  		and cl,3Fh			; Max sector number   129 00000030 880E[F200]              		mov [Sectors],cl   130                                  		; Note: we actually don't care about the number of   131                                  		; cylinders, since that's the highest-order division   132                                     133                                  ;   134                                  ; Now look for one (and only one) active partition.   135                                  ;   136 00000034 BE[BE01]                		mov si,PartitionTable   137 00000037 31C0                    		xor ax,ax   138 00000039 B90400                  		mov cx,4

⌨️ 快捷键说明

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