load lba 1

main
pantonshire 1 year ago
parent b0547844ed
commit 108040ae01

@ -46,22 +46,48 @@ bits 16
mov di, 0x00 mov di, 0x00
mov ah, 0x08 mov ah, 0x08
int 0x13 int 0x13
jb panic jc panic
and cl, 0x3f and cl, 0x3f ; sectors per track
mov [bp + 1], cl mov [bp + 1], cl
movzx ax, dh movzx bx, dh
add ax, 1 inc bx ; number of heads
mov [bp + 2], ax 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 ; Set VGA mode
; https://mendelson.org/wpdos/videomodes.txt ; https://mendelson.org/wpdos/videomodes.txt
mov ax, 0x0003 mov ax, 0x0003
int 0x10 int 0x10
mov word fs:[0x0000], 0xc048 ; mov word fs:[0x0000], 0xc048
mov word fs:[0x0002], 0xc069 ; 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 hlt
panic: panic:

@ -13,4 +13,5 @@ partition_disk:
parted --script disk.bin type 1 0fc63daf-8483-4772-8e79-3d69d8477de4 parted --script disk.bin type 1 0fc63daf-8483-4772-8e79-3d69d8477de4
write_stage0: write_stage0:
dd if=/dev/zero of=disk.bin bs=440 count=1 conv=notrunc
dd if=boot0.bin of=disk.bin conv=notrunc dd if=boot0.bin of=disk.bin conv=notrunc

Loading…
Cancel
Save