📄 rxd_boot.asm
字号:
xor dx, dx
div word ptr [ __bsHeads ]
; mov word ptr [ _readHead ][ bp ], ax ; don't need to save heads
; mov byte ptr [ _readTrack ][ bp ], dl ; dont need to save track
mov dh, dl ; track
clc
mov cl, 6
shl ah, cl ; move read head up
or ah, byte ptr [ _readSector ][ bp ] ; unused portion of sector
mov cx, ax
xchg ch, cl
mov ax, 0201h ; read one sector.
mov dl, byte ptr [ _readDrive ][ bp ]
int 13h
jnc RxDOSPerformRead_08
cmp ax, 11h ; ECC corrected data ?
jz RxDOSPerformRead_08 ; return no carry -->
stc
RxDOSPerformRead_08:
pop cx
pop ax
pop dx
pop bp
ret
RxDOS_RXDOSBIOCOM: db 'RXDOSBIOSYS'
RxDOS_RXDOSCOM: db 'RXDOS SYS'
RxDOS_DISKERROR: db 'Not an RxDOS system disk or disk error', 0Dh, 0Ah
db 'Press any key to continue...', 0Dh, 0Ah, 00h
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; partition table
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
org RxDOS_START+200h-2
RxDOS_BootSignature: db 055h, 0AAh
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Write Stub ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; The stub loads at the normal 100h load address and writes ;
; the boot sector to drive A: ;
;...............................................................;
org 100h
RxDOS_WRITESTUB:
cli
cld
push cs
pop ss
mov sp, offset RxDOS_WRITESTUB_STACK
sti
mov dx, cs
mov ds, dx
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; see if drive specified
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Entry
def _drive, 0000 ; A:
def _WriteOnce, FALSE
def _SilentMode, FALSE
def _isRemovable, TRUE
mov si, offset 80h
mov cl, byte ptr es:[ si ]
or cl, cl ; arguments passed in command line ?
jz RxDOS_WRITESTUB_36 ; no, default to A: -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; switch processing
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_06:
inc si
mov al, byte ptr es:[ si ] ; scan command line
cmp al, ControlM ; command line end ?
jz RxDOS_WRITESTUB_36 ; yes -->
cmp al, ' ' ; space ?
jz RxDOS_WRITESTUB_06 ; skip any leading spaces -->
cmp al, '-' ; switch character ?
jz RxDOS_WRITESTUB_10 ; yes -->
cmp al, '/' ; switch character ?
jnz RxDOS_WRITESTUB_22 ; no -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; see if -1 (write once )
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_10:
inc si
mov al, byte ptr es:[ si ] ; get switch character
cmp al, '1' ; write once ?
jnz RxDOS_WRITESTUB_12 ; no -->
storarg _WriteOnce, TRUE ; set write once mode
jmp RxDOS_WRITESTUB_06
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; see if -s (silent mode)
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_12:
cmp al, 's' ; silent mode ?
jz RxDOS_WRITESTUB_14 ; yes -->
cmp al, 'S' ; silent mode ?
jnz RxDOS_WRITESTUB_16 ; no -->
RxDOS_WRITESTUB_14:
storarg _SilentMode, TRUE ; set silent mode
storarg _WriteOnce, TRUE ; silent makes -> write once mode
jmp RxDOS_WRITESTUB_06
RxDOS_WRITESTUB_16:
cmp al, ControlM ; command line end ?
jnz RxDOS_WRITESTUB_06 ; not yet -->
jmp short RxDOS_WRITESTUB_36
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; drive letter processing
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_22:
mov bl, al ; get character
sub bl, '0' ; allow 0 as A:
jc RxDOS_WRITESTUB_36 ;
cmp al, '9' + 1 ; allow number for drive
jc RxDOS_WRITESTUB_32 ;
mov bl, al
sub bl, 'A' ; A - Z
jc RxDOS_WRITESTUB_36 ;
cmp al, 'Z' + 1 ;
jc RxDOS_WRITESTUB_32 ;
mov bl, al
sub bl, 'a' ; a - z
jc RxDOS_WRITESTUB_36 ;
cmp al, 'z' + 1 ;
jc RxDOS_WRITESTUB_32 ;
jmp RxDOS_WRITESTUB_InvalidDrive ; cannot set invalid drive -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get drive code, test if removable
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_32:
mov byte ptr [ _drive ][ bp ], bl ; set drive if other than A:
RxDOS_WRITESTUB_36:
mov bl, byte ptr [ _drive ][ bp ]
inc bl
Int21 IoControl, 08h ; is drive removable ?
ifc RxDOS_WRITESTUB_InvalidDrive ; invalid drive -->
not ax ; 0000 if removable,
and ax, 1 ; ... convert to true or false
mov word ptr [ _isRemovable ][ bp ], ax ;
mov bl, byte ptr [ _drive ][ bp ]
inc bl
Int21 IoControl, 09h ; is drive remote ?
jc RxDOS_WRITESTUB_40 ; ignore possible unsupported error -->
test dx, 1000h ; remote flag set ?
ifnz RxDOS_WRITESTUB_InvalidDrive ; cannot set invalid drive -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; Write message
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_40:
mov dl, byte ptr [ _drive ][ bp ]
add dl, 'A'
mov byte ptr RxDOS_PressKeyWhenReady_Drive, dl
cmp word ptr [ _SilentMode ][ bp ], 0 ; silent mode ?
jnz RxDOS_WRITESTUB_46 ; ok to write -->
mov si, offset RxDOS_PressKeyWhenReady
call RxDOSLOAD_DisplayMsg
RxDOS_WRITESTUB_42:
xor ax, ax
int 16h ; wait for keyboard command
cmp al, ControlM
jz RxDOS_WRITESTUB_46
cmp al, ' '
jz RxDOS_WRITESTUB_46
cmp al, 'n'
ifz RxDOS_WRITESTUB_80 ; if no -->
cmp al, 'N'
ifz RxDOS_WRITESTUB_80 ; if no -->
cmp al, 'C'-40h
ifz RxDOS_WRITESTUB_80 ; if no -->
jmp RxDOS_WRITESTUB_42
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if floppy drive,
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_46:
push cs
pop es ; restore es:
RxDOS_WRITESTUB_48:
mov dl, byte ptr [ _drive ][ bp ]
call _ReadBootSector ; read current information
jc RxDOS_WRITESTUB_68 ; if error -->
cld
mov si, offset [ _rwBUFFER. _bsBytesPerSector ]
mov di, offset [ __bsBytesPerSector ]
mov cx, ( __bsDriveNumber - __bsBytesPerSector )
rep movsb ; copy these parameters
mov si, offset [ RxDOS_OEMNAME ]
mov di, offset [ __bsOemName ]
mov cx, 8
rep movsb ; copy product name
push es
xor ax, ax
mov es, ax
mov ax, word ptr es:[ 46Ch ]
mov dx, word ptr es:[ 46Eh ]
pop es
mov word ptr [ __bsVolumeId. _High ], dx
mov word ptr [ __bsVolumeId. _Low ], ax
xor dx, dx
mov dl, byte ptr [ _drive ][ bp ]
call _WriteBootSector ; write boot sector
jnc RxDOS_WRITESTUB_72 ; if everything is ok -->
RxDOS_WRITESTUB_68:
mov si, offset RxDOS_diskA_NotReadyOrError
call RxDOSLOAD_DisplayMsg
jmp short RxDOS_WRITESTUB_76
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; success. try again ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
RxDOS_WRITESTUB_72:
mov si, offset RxDOS_diskA_WrittenSuccesfully
call RxDOSLOAD_DisplayMsg
cmp word ptr [ _WriteOnce ][ bp ], TRUE
jz RxDOS_WRITESTUB_80
mov si, offset RxDOS_diskA_WriteAnother
call RxDOSLOAD_DisplayMsg
RxDOS_WRITESTUB_76:
xor ax, ax
int 16h ; wait for keyboard command
cmp al, 'n'
jz RxDOS_WRITESTUB_80 ; if no -->
cmp al, 'N'
jz RxDOS_WRITESTUB_80 ; if no -->
cmp al, 'C'-40h
jz RxDOS_WRITESTUB_80 ; if cancel -->
jmp RxDOS_WRITESTUB_40 ; else if retry -->
RxDOS_WRITESTUB_80:
Int21 TerminateProcess, 00
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; messages
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -