Read all the sectors
This commit is contained in:
parent
bd62352513
commit
2d21f3114f
2 changed files with 18 additions and 4 deletions
BIN
drive.bin
BIN
drive.bin
Binary file not shown.
22
main.asm
22
main.asm
|
@ -1,3 +1,5 @@
|
||||||
|
DISK_ID EQU 0x81
|
||||||
|
|
||||||
org 0x7C00
|
org 0x7C00
|
||||||
bits 16
|
bits 16
|
||||||
|
|
||||||
|
@ -75,7 +77,7 @@ ret
|
||||||
|
|
||||||
; reset disk system
|
; reset disk system
|
||||||
mov ah, 0x00
|
mov ah, 0x00
|
||||||
mov dl, 0x81
|
mov dl, DISK_ID
|
||||||
int 0x13
|
int 0x13
|
||||||
|
|
||||||
; print result on error
|
; print result on error
|
||||||
|
@ -84,16 +86,23 @@ mov bl, ah
|
||||||
call .puthex
|
call .puthex
|
||||||
.reset_disk_no_error:
|
.reset_disk_no_error:
|
||||||
|
|
||||||
; Read sector 1 into memory
|
push byte 0
|
||||||
|
.read_disk_loop
|
||||||
|
pop cx
|
||||||
|
inc cl
|
||||||
|
push cx
|
||||||
|
|
||||||
|
; Read sector dl into memory
|
||||||
mov ah, 0x02
|
mov ah, 0x02
|
||||||
mov al, 0x01 ; number of sectors
|
mov al, 0x01 ; number of sectors
|
||||||
mov ch, 0x00 ; cylinder number, low 8 bits
|
mov ch, 0x00 ; cylinder number, low 8 bits
|
||||||
mov cl, 0x01 ; cylinder number, high 2 bits + sector number (6 bits)
|
; mov cl, 0x01 ; cylinder number, high 2 bits + sector number (6 bits)
|
||||||
mov dh, 0x00 ; head number
|
mov dh, 0x00 ; head number
|
||||||
mov dl, 0x81 ; drive number
|
mov dl, DISK_ID ; drive number
|
||||||
mov bx, .data ; data buffer
|
mov bx, .data ; data buffer
|
||||||
int 0x13
|
int 0x13
|
||||||
|
|
||||||
|
jc .read_disk_error
|
||||||
; print result on error
|
; print result on error
|
||||||
jnc .read_disk_no_error
|
jnc .read_disk_no_error
|
||||||
mov bl, ah
|
mov bl, ah
|
||||||
|
@ -103,11 +112,16 @@ call .puthex
|
||||||
; print string
|
; print string
|
||||||
mov bx, .data
|
mov bx, .data
|
||||||
call .puts
|
call .puts
|
||||||
|
jmp .read_disk_loop
|
||||||
|
.read_disk_error:
|
||||||
|
|
||||||
.end:
|
.end:
|
||||||
hlt
|
hlt
|
||||||
|
|
||||||
.data:
|
.data:
|
||||||
|
|
||||||
|
; print padding nullbytes
|
||||||
times 510 - ($ - $$) db 0
|
times 510 - ($ - $$) db 0
|
||||||
|
|
||||||
|
; write magic string
|
||||||
dw 0xAA55
|
dw 0xAA55
|
Loading…
Reference in a new issue