📄 rxdosbio.asm
字号:
jmp short getNextCluster_Return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; 16 bit FAT entries
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getNextCluster_16Bits:
mov cx, word ptr [ BootDrive_BPB. _bpbBytesPerSector ]
shr cx, 1
div cx ; FAT sector/ Offset
; ax will contain FAT sector
; dx will contain byte offset into FAT sector
add dx, dx ; make word offset
push dx
xor cx, cx
mov dx, word ptr [ BootDrive_BPB. _bpbResSectors ] ; where is first FAT table ?
add dx, ax ; add offset required
mov ax, word ptr [ _drive ][ bp ] ; get drive
call ReadFATBuffer ; read FAT Table
pop bx ; word offset into FAT table
mov dx, word ptr es:[ bx + di ] ; get FAT word
mov ax, dx
and ax, 0FFF8h ; FAT value, 12 bit entries.
cmp ax, 0FFF8h ; end of chain ?
jnz getNextCluster_Return ; no -->
mov dx, -1 ; if end, set end value
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getNextCluster_Return:
restoreRegisters ax, bx, cx, si, di, es
cmp dx, -1 ; set if end of chain
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Scan Ahead Cluster Map ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx current cluster ;
; ;
; Output: ;
; cx # sectors to sequentially read ;
; dx last cluster value ;
;...............................................................;
scanClusterMap:
Entry
def _drive, ax
def _cluster, dx
def _nextCluster
def _clusterCount, 0000
scanClusterMap_12:
inc word ptr [ _clusterCount ][ bp ] ; cluster count
mov cx, dx
call getNextCluster ; get next cluster
cmp dx, -1 ; end ?
jz scanClusterMap_22 ; yes -->
sub cx, dx ; sequential clusters are ...
cmp cx, -1 ; ... identified by a -1 offset
jz scanClusterMap_12 ; if still sequential -->
scanClusterMap_22:
mov ax, word ptr [ _clusterCount ][ bp ] ; # sequential clusters
mul byte ptr [ BootDrive_BPB. _bpbSectorsPerCluster ]
mov cx, ax ; # sectors to sequentially read
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Get 12Bit FAT Table Value ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; dx current cluster ;
; ;
; Output: ;
; dx value at cluster (next cluster) ;
; zr if end of cluster chain. ;
;...............................................................;
_get_12Bit_ClusterValue:
Entry
def _drive, ax
def _cluster, dx
def _sectorsize
ddef _sector
mov ax, dx
add ax, ax
add ax, dx ; nibble address
xor dx, dx
mov cx, word ptr [ BootDrive_BPB. _bpbBytesPerSector ]
mov word ptr [ _sectorsize ][ bp ], cx
dec word ptr [ _sectorsize ][ bp ]
shl cx, 1 ; nibbles / sector
div cx ; sector to read
; ax will contain sector
; dx will contain nibble offset
shr dx, 1 ; word offset
push dx ;
xor cx, cx ; 32 bit address
mov dx, ax
add dx, word ptr [ BootDrive_BPB. _bpbResSectors ] ; where is first FAT table ?
stordarg _sector, cx, dx ; 32 bit sector address
mov ax, word ptr [ _drive ][ bp ] ; get drive
call ReadFATBuffer ; read FAT Table
pop bx ; word offset into FAT table
mov dx, word ptr es:[ bx + di ] ; get FAT word
cmp bx, word ptr [ _sectorsize ][ bp ] ; at sector size -1 boundry ?
jnz _get_12Bit_ClusterValue_12 ; no, ok to return as is -->
push dx ; else save what we have
getdarg cx, dx, _sector ; read next cluster sector
add dx, 0001 ; incr by one
adc cx, 0000
mov ax, word ptr [ _drive ][ bp ] ; get drive
call ReadFATBuffer ; read FAT Table
pop dx
mov dh, byte ptr es:[ di ] ; get FAT word at start of buffer
_get_12Bit_ClusterValue_12:
test word ptr [ _cluster ][ bp ], 1 ; is cluster Odd ?
jz _get_12Bit_ClusterValue_14 ; no, just take value -->
shr dx, 1
shr dx, 1
shr dx, 1
shr dx, 1
_get_12Bit_ClusterValue_14:
and dx, 0FFFh ; 12 bit mask
mov ax, dx
and ax, 00FF8h ; FAT value, 12 bit entries.
cmp ax, 00FF8h ; end of chain ?
jnz _get_12Bit_ClusterValue_16 ; no -->
mov dx, -1 ; if end, set end value
_get_12Bit_ClusterValue_16:
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Error Display ;
;...............................................................;
RxDOSBIOS_Error:
mov si, offset RXDOSBIO_MSGErrorLoadingSystem
call _DisplayMsg
RxDOSBIOS_Error_04:
xor ax, ax
int 16h
jmp RxDOSBIOS_Error_04
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Display Message ;
;...............................................................;
_DisplayMsg:
push cs
pop ds
_DisplayMsg_02:
lodsb ; get character (ds:si)
or al, al ; null terminator ?
jnz _DisplayMsg_06 ; not yet -->
ret
_DisplayMsg_06:
push si
mov ah, 0Eh
mov bx, 0007h
int 10h
pop si
jmp _DisplayMsg_02
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Init Interrupt Vectors ;
;...............................................................;
InitInterruptVectors:
mov word ptr es:[ _segment ][ bx ], cs
mov word ptr es:[ _pointer ][ bx ], offset IntReturn
add bx, 4
loop InitInterruptVectors
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Initialize ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; The boot loader loader transfers control to here with the ;
; following arguments: ;
; ;
; CH media descriptor byte ;
; DL unit address of startup drive ;
; AX:BX sector address of root directory ;
; DS:SI BIOS parameter table ;
; ;
; int 1E address contains a pointer to the current drive DISK ;
; PARAMETER Table. ;
; ;
;...............................................................;
RxDOSBIOS_Initialize:
cli
cld
mov word ptr cs:[ diskParameterTable. _pointer ], si
mov word ptr cs:[ diskParameterTable. _segment ], ds
mov byte ptr cs:[ BootDrive ], dl ; physical drive (80, ... )
mov ax, cs
mov ds, ax ; DS:
mov es, ax ; ES:
mov ss, ax ; SS:
mov sp, offset RxDOSBIOS_LastAddress + 1024 ; temporary stack
sti
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; copy BPB from boot record (at 0:7C0Bh)
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
push ds
xor ax, ax
mov ds, ax ; disk boot table
mov si, 7C0Bh ; at 0000:7C0B
mov di, offset BootDrive_BPB
mov cx, sizeBPB
rep movsb ; copy BPB
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; get cluster address of RXDOSBIO.SYS and RXDOS.SYS
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
pop ds
xor ax, ax
mov es, ax ; ES:
mov si, 500h ; where root directory is located
mov ax, word ptr es:[ RXDOSBIO_SYS. deStartCluster ][ si ]
mov dx, word ptr es:[ RXDOS_SYS. deStartCluster ][ si ]
mov word ptr [ RXDOSBIO_ClusterAddr ], ax
mov word ptr [ RXDOS_ClusterAddr ], dx
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; relocate disk parameter table to safe address ( at, surprisingly, 0:522 )
; we move it here to maintain some strange compatability with the other DOS.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -