|
|
|
|
@ -46,22 +46,48 @@ bits 16
|
|
|
|
|
mov di, 0x00
|
|
|
|
|
mov ah, 0x08
|
|
|
|
|
int 0x13
|
|
|
|
|
jb panic
|
|
|
|
|
and cl, 0x3f
|
|
|
|
|
jc panic
|
|
|
|
|
and cl, 0x3f ; sectors per track
|
|
|
|
|
mov [bp + 1], cl
|
|
|
|
|
movzx ax, dh
|
|
|
|
|
add ax, 1
|
|
|
|
|
mov [bp + 2], ax
|
|
|
|
|
|
|
|
|
|
movzx bx, dh
|
|
|
|
|
inc bx ; number of heads
|
|
|
|
|
mov [bp + 2], bx
|
|
|
|
|
|
|
|
|
|
; Load LBA 1.
|
|
|
|
|
cmp cl, 1 ; division of 1 by nonzero can be done with cmp
|
|
|
|
|
sete al ; temp = LBA / (sectors per track)
|
|
|
|
|
setne cl ; sector - 1 = LBA % (sectors per track)
|
|
|
|
|
inc cl
|
|
|
|
|
xor ah, ah ; zero-extend temp
|
|
|
|
|
xor dx, dx ; TODO: explain why this is needed for div
|
|
|
|
|
div bx ; ah = mod (head), al = div (cylinder)
|
|
|
|
|
|
|
|
|
|
mov dh, ah ; head
|
|
|
|
|
mov ch, al ; cylinder
|
|
|
|
|
; we already have sector in cl
|
|
|
|
|
mov ah, 2 ; read disk
|
|
|
|
|
mov al, 1 ; load one sector
|
|
|
|
|
mov bx, 0x7e00
|
|
|
|
|
mov dl, [bp] ; drive number
|
|
|
|
|
int 0x13
|
|
|
|
|
jc panic
|
|
|
|
|
|
|
|
|
|
; head = temp % number of heads
|
|
|
|
|
; cylinder = temp / number of heads
|
|
|
|
|
|
|
|
|
|
; Set VGA mode
|
|
|
|
|
; https://mendelson.org/wpdos/videomodes.txt
|
|
|
|
|
mov ax, 0x0003
|
|
|
|
|
int 0x10
|
|
|
|
|
|
|
|
|
|
mov word fs:[0x0000], 0xc048
|
|
|
|
|
mov word fs:[0x0002], 0xc069
|
|
|
|
|
; mov word fs:[0x0000], 0xc048
|
|
|
|
|
; mov word fs:[0x0002], 0xc069
|
|
|
|
|
mov al, [0x7e00]
|
|
|
|
|
mov byte fs:[0x0000], al
|
|
|
|
|
mov al, [0x7e01]
|
|
|
|
|
mov byte fs:[0x0002], al
|
|
|
|
|
mov al, [0x7e02]
|
|
|
|
|
mov byte fs:[0x0004], al
|
|
|
|
|
hlt
|
|
|
|
|
|
|
|
|
|
panic:
|
|
|
|
|
|