forked from offtopia/ponydos
Merge read/write to modify_sector
This commit is contained in:
parent
d6dc33f164
commit
400f282725
66
ponydos.asm
66
ponydos.asm
|
@ -171,24 +171,31 @@ read_sectors:
|
|||
push ax
|
||||
push cx
|
||||
push bx
|
||||
push di
|
||||
|
||||
xor di, di
|
||||
.loop:
|
||||
call read_sector
|
||||
call modify_sector
|
||||
inc ax
|
||||
add bx, 512
|
||||
loop .loop
|
||||
|
||||
pop di
|
||||
pop bx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
; in:
|
||||
; ax = LBA of sector
|
||||
; out:
|
||||
; cx, dx = appropriately set for int 0x13
|
||||
; ax clobbered
|
||||
prepare_geometry:
|
||||
; ax = LBA of first sector
|
||||
;; bl = drive number, use [boot_disk] for now
|
||||
; es:bx = output buffer
|
||||
; di = 0x0100 for write, 0x0000 for read
|
||||
modify_sector:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
|
||||
mov cx, 18
|
||||
div cx
|
||||
|
||||
|
@ -206,21 +213,10 @@ prepare_geometry:
|
|||
|
||||
; dl = drive number
|
||||
mov dl, [boot_disk]
|
||||
ret
|
||||
|
||||
; in:
|
||||
; ax = LBA of first sector
|
||||
;; bl = drive number, use [boot_disk] for now
|
||||
; es:bx = output buffer
|
||||
read_sector:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
|
||||
call prepare_geometry
|
||||
|
||||
.retry:
|
||||
mov ax, 0x0201 ; read one sector
|
||||
mov ax, 0x0201 ; read/write one sector
|
||||
add ax, di
|
||||
int 0x13
|
||||
jc .error
|
||||
|
||||
|
@ -237,32 +233,6 @@ read_sector:
|
|||
int 0x10
|
||||
jmp .retry
|
||||
|
||||
; in:
|
||||
; ax = LBA of first sector
|
||||
;; bl = drive number, use [boot_disk] for now
|
||||
; es:bx = input buffer
|
||||
write_sector:
|
||||
push ax
|
||||
push cx
|
||||
push dx
|
||||
|
||||
call prepare_geometry
|
||||
|
||||
.retry:
|
||||
mov ax, 0x0301 ; write one sector
|
||||
int 0x13
|
||||
jc .error
|
||||
|
||||
pop dx
|
||||
pop cx
|
||||
pop ax
|
||||
ret
|
||||
|
||||
.error:
|
||||
xor ah, ah
|
||||
int 0x10
|
||||
jmp .retry
|
||||
|
||||
; ------------------------------------------------------------------
|
||||
; Filesystem
|
||||
; ------------------------------------------------------------------
|
||||
|
@ -290,7 +260,8 @@ open_file:
|
|||
;mov ax, 1
|
||||
mov al, 1
|
||||
mov bx, DIRENTS
|
||||
call read_sector
|
||||
xor di, di
|
||||
call modify_sector
|
||||
|
||||
mov ax, 2
|
||||
mov di, bx
|
||||
|
@ -336,7 +307,8 @@ open_file:
|
|||
push ax
|
||||
mov ax, 1
|
||||
;mov bx, DIRENTS
|
||||
call write_sector
|
||||
mov di, 0x0100 ; write
|
||||
call modify_sector
|
||||
pop ax
|
||||
|
||||
;mov cx, 1
|
||||
|
|
Loading…
Reference in New Issue