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

📄 rxd_boot.asm

📁 dos source
💻 ASM
📖 第 1 页 / 共 3 页
字号:
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

RxDOS_WRITESTUB_InvalidDrive:
        mov si, offset RxDOS_InvalidDrive
        call RxDOSLOAD_DisplayMsg
        Int21 TerminateProcess, 02
        jmp RxDOS_WRITESTUB_InvalidDrive

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Read Boot Sector for ANY drive                               ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;    dx     drive ( 0 = A:, 1 = B:, 2 = C:, ... )               ;
        ;                                                               ;
        ;                                                               ;
        ;                                                               ;
        ;...............................................................;

_ReadBootSector:

        Entry
        def  _drive, dx                                 ; 0 = A:, 1 = B:, 2 = C:, ...
        def  _retries, 3                                ; max retries
        ddef _drivePB                                   ; drive parameter block
        ddef _strategy
        ddef _interrupt

        push ds
        mov dl, byte ptr [ _drive ][ bp ]
        inc dl                                          ; 1 = A:, ...
        Int21 GetDriveParameterBlock                    ; get pointer to drive data
        stordarg _drivePB, ds, bx                       ; drive parameter bloc

        pop ds
        cmp al, -1                                      ; invalid drive or error ?
        jnz _ReadBootSector_08                          ; no, ok -->
        stc
        Return

_ReadBootSector_08:
        mov bx, offset _ReqBlock
        mov byte ptr [ rwrLength   ][ bx ], sizeREADReqHeader
        mov byte ptr [ rwrFunction ][ bx ], DEVICEREAD

        mov al, byte ptr [ _drive ][ bp ]
        mov byte ptr [ rwrUnit ][ bx ], al

        getdarg es, si, _drivePB                        ; drive parameter bloc
        mov al, byte ptr es:[ _dpbMediaDescriptor ][ si ]
        mov byte ptr [ rwrMediaID ][ bx ], al

        mov word ptr [ rwrBytesReq ][ bx ], 1           ; one sector
        mov word ptr [ rwrStartSec ][ bx ], 0000        ; address
        mov word ptr [ rwrHugeStartSec. _high ][ bx ], 0000
        mov word ptr [ rwrHugeStartSec. _low  ][ bx ], 0000

        mov word ptr [ rwrBuffer. _pointer   ][ bx ], offset _rwBUFFER
        mov word ptr [ rwrBuffer. _segment   ][ bx ], cs
        mov word ptr [ rwrVolumeID. _pointer ][ bx ], offset _rwVOLBUFFER
        mov word ptr [ rwrVolumeID. _segment ][ bx ], cs

        les bx, dword ptr es:[ _dpbptrDeviceDriver ][ si ]
        mov ax, word ptr es:[ devStrategy  ][ bx ]
        stordarg _strategy, es, ax

        mov ax, word ptr es:[ devInterrupt ][ bx ]
        stordarg _interrupt, es, ax

_ReadBootSector_18:
        push ds
        pop es
        mov bx, offset _ReqBlock
        mov word ptr [ rwrStatus   ][ bx ], 0000
        call dword ptr [ _strategy ][ bp ]              ; strategy
        call dword ptr [ _interrupt ][ bp ]             ; interrupt

      ; dec word ptr [ _retries ][ bp ]                 ; retries
      ; jnz _ReadBootSector_18

        clc
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Write Boot Sector for ANY drive                              ;
        ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
        ;                                                               ;
        ;  Usage:                                                       ;
        ;    dx     drive ( 0 = A:, 1 = B:, 2 = C:, ... )               ;
        ;                                                               ;
        ;...............................................................;

_WriteBootSector:

        Entry
        def  _drive, dx                                 ; 0 = A:, 1 = B:, 2 = C:, ...
        def  _retries, 3                                ; max retries
        ddef _drivePB                                   ; drive parameter block
        ddef _strategy
        ddef _interrupt

        push ds
        mov dl, byte ptr [ _drive ][ bp ]
        inc dl                                          ; 1 = A:, ...
        Int21 GetDriveParameterBlock                    ; get pointer to drive data
        stordarg _drivePB, ds, bx                       ; drive parameter bloc

        pop ds
        cmp al, -1                                      ; invalid drive or error ?
        jnz _WriteBootSector_08                         ; no, ok -->
        stc
        Return

_WriteBootSector_08:
        mov bx, offset _ReqBlock
        mov byte ptr [ rwrLength   ][ bx ], sizeREADReqHeader
        mov byte ptr [ rwrFunction ][ bx ], DEVICEWRITE
        mov word ptr [ rwrStatus   ][ bx ], 0000

        mov al, byte ptr [ _drive ][ bp ]
        mov byte ptr [ rwrUnit ][ bx ], al

        getdarg es, si, _drivePB                        ; drive parameter bloc
        mov al, byte ptr es:[ _dpbMediaDescriptor ][ si ]
        mov byte ptr [ rwrMediaID ][ bx ], al

        mov word ptr [ rwrBytesReq ][ bx ], 1           ; one sector
        mov word ptr [ rwrStartSec ][ bx ], 0000        ; address
        mov word ptr [ rwrHugeStartSec. _high ][ bx ], 0000
        mov word ptr [ rwrHugeStartSec. _low  ][ bx ], 0000

        mov word ptr [ rwrBuffer. _pointer   ][ bx ], offset RxDOS_START
        mov word ptr [ rwrBuffer. _segment   ][ bx ], cs
        mov word ptr [ rwrVolumeID. _pointer ][ bx ], offset _rwVOLBUFFER
        mov word ptr [ rwrVolumeID. _segment ][ bx ], cs

        les bx, dword ptr es:[ _dpbptrDeviceDriver ][ si ]
        mov ax, word ptr es:[ devStrategy  ][ bx ]
        stordarg _strategy, es, ax

        mov ax, word ptr es:[ devInterrupt ][ bx ]
        stordarg _interrupt, es, ax

_WriteBootSector_18:
        push ds
        pop es
        mov bx, offset _ReqBlock
        call dword ptr [ _strategy ][ bp ]              ; strategy
        call dword ptr [ _interrupt ][ bp ]             ; interrupt

      ; dec word ptr [ _retries ][ bp ]                 ; retries
      ; jnz _WriteBootSector_18

        clc
        Return

        ;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
        ;  Messages                                                     ;
        ;...............................................................;

RxDOS_OEMNAME:
        db 'RxDOS6.0'

RxDOS_Welcome:
        db 0Dh, 0Ah
        db 0Dh, 0Ah, 'RxDOS Write Boot Sector Utility. '
        db 0Dh, 0Ah, 'Usage: rxd_boot [drive]'
        db 0Dh, 0Ah, 0

RxDOS_PressKeyWhenReady:
        db 0Dh, 0Ah, 0Dh, 0Ah, 'Press Space to write boot sector on disk '

RxDOS_PressKeyWhenReady_Drive:
        db 'A. ', 0

RxDOS_diskA_WriteAnother:
        db 0Dh, 0Ah, 'Disk updated. Would you like to write another? ', 0

RxDOS_diskA_WrittenSuccesfully:
        db 0Dh, 0Ah, 'Disk updated. ', 0

RxDOS_diskA_NotReadyOrError:
        db 0Dh, 0Ah, 'Disk error or drive not ready. Try again? ', 0

RxDOS_InvalidDrive:
        db 0Dh, 0Ah, 'Drive is invalid. Cannot write boot sector. ', 0

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  stack for stub
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                      even
                        dw 400h dup(0)
RxDOS_WRITESTUB_STACK:  dw 0

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  Drive Default Data
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        
DriveDefaultData:

    ; 360k drive

        dw sizeSector                           ; __bsBytesPerSector
        db 2                                    ; __bsSectorsPerCluster
        dw 1                                    ; __bsResSectors
        db 2                                    ; __bsNumCopiesFAT
        dw 112                                  ; __bsMaxAllocRootDir
        dw 720                                  ; __bsMaxSectors
        db 0FDh                                 ; __bsMediaDescriptor
        dw 2                                    ; __bsSectorsPerFat
        dw 9                                    ; __bsSectorsPerTrack
        dw 2                                    ; __bsHeads
        dd 0                                    ; __bsHiddenSectors
        dd 0                                    ; __bsHugeSectors

    ; 1.2M drive

        dw sizeSector                           ; __bsBytesPerSector
        db 1                                    ; __bsSectorsPerCluster
        dw 1                                    ; __bsResSectors
        db 2                                    ; __bsNumCopiesFAT
        dw 224                                  ; __bsMaxAllocRootDir
        dw 2400                                 ; __bsMaxSectors
        db 0F9h                                 ; __bsMediaDescriptor
        dw 7                                    ; __bsSectorsPerFat
        dw 15                                   ; __bsSectorsPerTrack
        dw 2                                    ; __bsHeads
        dd 0                                    ; __bsHiddenSectors
        dd 0                                    ; __bsHugeSectors

    ; 720k drive

        dw sizeSector                           ; __bsBytesPerSector
        db 2                                    ; __bsSectorsPerCluster
        dw 1                                    ; __bsResSectors
        db 2                                    ; __bsNumCopiesFAT
        dw 112                                  ; __bsMaxAllocRootDir
        dw 1440                                 ; __bsMaxSectors
        db 0F9h                                 ; __bsMediaDescriptor
        dw 3                                    ; __bsSectorsPerFat
        dw 9                                    ; __bsSectorsPerTrack
        dw 2                                    ; __bsHeads
        dd 0                                    ; __bsHiddenSectors
        dd 0                                    ; __bsHugeSectors

    ; 1.44M drive

        dw sizeSector                           ; __bsBytesPerSector
        db 1                                    ; __bsSectorsPerCluster
        dw 1                                    ; __bsResSectors
        db 2                                    ; __bsNumCopiesFAT
        dw 224                                  ; __bsMaxAllocRootDir
        dw 2880                                 ; __bsMaxSectors
        db 0F0h                                 ; __bsMediaDescriptor
        dw 9                                    ; __bsSectorsPerFat
        dw 18                                   ; __bsSectorsPerTrack
        dw 2                                    ; __bsHeads
        dd 0                                    ; __bsHiddenSectors
        dd 0                                    ; __bsHugeSectors

        dw -1

;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
;  working sector buffer
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

                      even
_ReqBlock:              db sizeREADReqHeader dup(0)

_rwBUFFER:              db sizeSector dup(0)
_rwVOLBUFFER:           db sizeSector dup(0)

RxDOSBOOT               ENDS
                        END  RxDOS_WRITESTUB

⌨️ 快捷键说明

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