📄 rxd_boot.asm
字号:
TITLE 'RxDOS Boot Sector Program'
PAGE 59, 132
.LALL
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; RxDOS Boot Sector Program ;
;...............................................................;
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Real Time Dos ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This material was created as a published version of a DOS ;
; equivalent product. This program logically functions in ;
; the same way as MSDOS functions and it is internal data ;
; structure compliant with MSDOS 6.0 ;
; ;
; This product is distributed AS IS and contains no warranty ;
; whatsoever, including warranty of merchantability or ;
; fitness for a particular purpose. ;
; ;
; ;
; (c) Copyright 1990, 1997. Api Software and Mike Podanoffsky ;
; All Rights Reserved Worldwide. ;
; ;
; This product is protected under copyright laws and may not ;
; be reproduced in whole or in part, in any form or media, ;
; included but not limited to source listing, facsimile, data ;
; transmission, cd-rom, or floppy disk without the expressed ;
; written consent of the author. ;
; ;
; License for distribution for commercial use or resale ;
; required from: ;
; ;
; Api Software ;
; 12 South Walker Street ;
; Lowell, MA 01851 ;
; ;
; internet: mikep@world.std.com ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; Compile with MASM 5.1 ;
;...............................................................;
include rxdosmac.asm
include rxdosdef.asm
RxDOSBOOT SEGMENT PUBLIC 'CODE'
assume cs:RxDOSBOOT, ds:RxDOSBOOT, es:RxDOSBOOT, ss:RxDOSBOOT
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Stack Arguments
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
even
_rootDirectory dd ?
_sizeRootDirectory dw ?
_readDrive dw ?
_readTrack dw ?
_readSector dw ?
_readHead dw ?
_diskParameterTable db 12 dup(?)
_stackReserved equ ($ - _diskParameterTable) + 20h
ROMBIOS_DISKTABLE equ ( 1Eh * 4 )
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; buffers start elsewhere
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org 500h
RXDOS_READBUFFER:
org 700h
RXDOS_DOSLOADBUFFER:
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; assume starts at 0000:7C00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org 7C00h
RxDOS_START: jmp RxDOS_LOAD
; this information is standard for every boot sector
__bsOemName db 'RxDOS6.0' ; 'RxDOS' if formatted by us
__bsBytesPerSector dw ? ; 512 is default
__bsSectorsPerCluster db ?
__bsResSectors dw ?
__bsNumCopiesFAT db ?
__bsMaxAllocRootDir dw ?
__bsMaxSectors dw ? ; if zero, see huge sectors
__bsMediaDescriptor db ?
__bsSectorsPerFat dw ?
__bsSectorsPerTrack dw ?
__bsHeads dw ?
__bsHiddenSectors dd ?
__bsHugeSectors dd ?
__bsDriveNumber db 0
db 0
__bsBootSignature db 29h ; 29h if extended boot sector
__bsVolumeId dd 0 ; unique disk ID
__bsVolumeLabel db sizeVolumeLabel dup(' '); not same as DOS Volume Id
__bsFileSystemType db 'FAT12 '
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; the RxDOS boot process begins here
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_LOAD:
cli ; no interrupts
cld ; all that we need to init
xor ax, ax
mov ds, ax ; allow debugging
mov es, ax ; allow debugging
mov ss, ax ; allow debugging
mov sp, 7C00h - _stackReserved
mov bp, sp
mov byte ptr [ _readDrive ][ bp ], dl
mov bx, offset ROMBIOS_DISKTABLE ; int 1E
lds si, es:[ bx ] ; 0000:0078
lea di, offset [ _diskParameterTable ][ bp ]
mov word ptr es:[ _pointer ][ bx ], di
mov word ptr es:[ _segment ][ bx ], ss
mov cx, sizeDISKPARAM
rep movsb
sti
xor ax, ax
mov ds, ax
mov byte ptr [ _diskParameterTable. _dptHeadSettleTime ][ bp ], 15
mov cx, word ptr [ __bsSectorsPerTrack ]
mov byte ptr [ _diskParameterTable. _dptSectorsPerTrack ][ bp ], cl
int 13h ; reset disk drive (ax = 0)
jc RxDOSLOAD_Error ; if error -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if no huge sectors, fix up huge sectors
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
mov ax, word ptr [ __bsMaxSectors ]
or ax, ax ; not a huge address disk ?
jz RxDOSLOAD_08 ; yes -->
mov word ptr [ __bsHugeSectors ], ax
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; compute logical sector address of Root Directory
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSLOAD_08:
mov bp, sp ; restore stack frame.
xor ax, ax
mov al, byte ptr [ __bsNumCopiesFAT ]
mul word ptr [ __bsSectorsPerFat ]
add ax, word ptr [ __bsHiddenSectors. _low ]
adc dx, word ptr [ __bsHiddenSectors. _high ]
add ax, word ptr [ __bsResSectors ]
adc dx, 0000
mov word ptr [ _rootDirectory. _low ][ bp ], ax
mov word ptr [ _rootDirectory. _high ][ bp ], dx
; read first sector of Root Directory
mov bx, offset RXDOS_READBUFFER
call RxDOSPerformRead
jc RxDOSLOAD_Error ; if error -->
mov di, offset RXDOS_READBUFFER
mov si, offset RxDOS_RXDOSBIOCOM
mov cx, sizeFILENAME
rep cmpsb ; compare first name
jnz RxDOSLOAD_Error ; if not a system disk -->
mov di, offset (RXDOS_READBUFFER. sizeDIRENTRY)
mov cx, sizeFILENAME
rep cmpsb ; compare second name
jz RxDOSLOAD_LoadDOS ; if equal -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; can't load
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSLOAD_Error:
mov si, offset RxDOS_DISKERROR
call RxDOSLOAD_DisplayMsg
xor ax, ax
int 16h ; wait on any key
int 19h ; not expected to return
jmp RxDOSLOAD_Error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; load DOS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSLOAD_LoadDOS:
mov ax, word ptr [ __bsMaxAllocRootDir ]
add ax, (sizeSector / sizeDIRENTRY) - 1
mov cl, 4
shr ax, cl ; sectors used by directory
mov word ptr [ _sizeRootDirectory ][ bp ], ax ; save size
mov ax, word ptr [ RXDOS_READBUFFER. deStartCluster ]
dec ax
dec ax ; subtract 2
xor ch, ch
mov cl, [ __bsSectorsPerCluster ]
mul cx
add ax, word ptr [ _rootDirectory. _low ][ bp ]
adc dx, word ptr [ _rootDirectory. _high ][ bp ]
add ax, word ptr [ _sizeRootDirectory ][ bp ]
adc dx, 0000
mov bx, offset RXDOS_DOSLOADBUFFER ; where to load
mov cx, 3 ; read three sectors
RxDOSLOAD_LoadDOS_08:
call RxDOSPerformRead
jc RxDOSLOAD_Error ; if error -->
add bx, word ptr [ __bsBytesPerSector ]
add ax, 0001
adc dx, 0000
loop RxDOSLOAD_LoadDOS_08
mov ch, byte ptr [ __bsMediaDescriptor ]
mov dl, byte ptr [ _readDrive ][ bp ]
mov bx, word ptr [ _rootDirectory. _low ][ bp ]
mov ax, word ptr [ _rootDirectory. _high ][ bp ]
lea si, offset [ _diskParameterTable ][ bp ]
JMP_FAR 70h, 0000h ; RXDOS_DOSLOADBUFFER
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Display Message, wait for ANY key
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSLOAD_DisplayMsg:
lodsb ; get character (ds:si)
or al, al ; null terminator ?
jz RxDOSLOAD_Return ; done -->
push si
mov ah, 0Eh
mov bx, 0007h
int 10h
pop si
jmp RxDOSLOAD_DisplayMsg
RxDOSLOAD_Return:
ret
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; perform disk read
; ---------------------------------------------------------------
; dx:ax logical sector to read
; es:bx read buffer address
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOSPerformRead:
push bp
push dx
push ax
push cx
div word ptr [ __bsSectorsPerTrack ]
inc dl
mov byte ptr [ _readSector ][ bp ], dl
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -