Use uppercase non-struct constants for BPB
This commit is contained in:
parent
dc6035fe9d
commit
50aa6e4eec
4 changed files with 47 additions and 95 deletions
|
@ -1,60 +0,0 @@
|
|||
section .text
|
||||
|
||||
load_bpb: mov bx, [drive_ptr]
|
||||
; read word for "sectors per fat"
|
||||
mov ax, [diskbuf+0x016]
|
||||
xor dx, dx
|
||||
; if zero, we need to check dword in BPB 7.1
|
||||
test ax, ax
|
||||
jnz .short_sf
|
||||
; fail if BPB 7.1 signature is not present
|
||||
mov cl, [diskbuf+0x042]
|
||||
or cl, 1
|
||||
cmp cl, 0x29
|
||||
jne .err
|
||||
; load dword
|
||||
mov ax, [diskbuf+0x024]
|
||||
mov dx, [diskbuf+0x026]
|
||||
.short_sf:
|
||||
; store local value
|
||||
mov [bx+drive.fat_size], ax
|
||||
mov [bx+drive.fat_size+2], dx
|
||||
|
||||
; copy number of fat's
|
||||
xor ah, ah
|
||||
mov al, [diskbuf+0x010]
|
||||
mov [bx+drive.fat_num], ax
|
||||
|
||||
; copy number of root directory entries
|
||||
mov ax, [diskbuf+0x011]
|
||||
mov cl, 4
|
||||
shr ax, cl
|
||||
mov [bx+drive.dir_size], ax
|
||||
|
||||
; calculate offsets for everything
|
||||
xor ax, ax
|
||||
xor dx, dx
|
||||
; add reserved sectors
|
||||
add ax, [diskbuf+0x0B+bpb_rsc]
|
||||
adc ax, 0
|
||||
; save begin of FAT tables
|
||||
mov [bx+drive.fat_offset], ax
|
||||
mov [bx+drive.fat_offset+2], dx
|
||||
; add FAT size * FAT number
|
||||
mov cx, [bx+drive.fat_num]
|
||||
.floop: add ax, [bx+drive.fat_size]
|
||||
adc dx, [bx+drive.fat_size+2]
|
||||
loop .floop
|
||||
; save begin of root directories
|
||||
mov [bx+drive.dir_offset], ax
|
||||
mov [bx+drive.dir_offset+2], dx
|
||||
; add root directory size (might be zero)
|
||||
add ax, [bx+drive.dir_size]
|
||||
adc dx, 0
|
||||
; save start of data area
|
||||
mov [bx+drive.clus_offset], ax
|
||||
mov [bx+drive.clus_offset+2], dx
|
||||
|
||||
ret
|
||||
.err: stc
|
||||
ret
|
Loading…
Add table
Add a link
Reference in a new issue