Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions stage1/hdd/bootsect.asm
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ start:
lgdt [gdt]

cli

push dword 0
mov ebp, 0x10

mov eax, cr0
bts ax, 0
mov cr0, eax
Expand Down Expand Up @@ -114,17 +118,14 @@ err:

bits 32
vector:
mov eax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov ds, ebp
mov es, ebp
mov fs, ebp
mov gs, ebp
mov ss, ebp

and edx, 0xff

push 0

push edx

push stage2.size
Expand Down
30 changes: 17 additions & 13 deletions stage1/hdd/disk.asm
Original file line number Diff line number Diff line change
Expand Up @@ -34,28 +34,34 @@ read_sectors:
mov si, .drive_params
mov word [si], 30 ; buf_size
int 0x13
jc .done
mov bp, word [si+24] ; bytes_per_sect
pushf
movzx ebp, word [si+24] ; bytes_per_sect

; ECX byte count to CX sector count
mov ax, cx
shr ecx, 16
mov dx, cx
mov eax, ecx
xor edx, edx
div ebp
xor cx, cx
div bp
test dx, dx
setnz cl
add cx, ax

popf
pop edx
pop eax

pop si
jc .done

; EBP:EAX address to EAX LBA sector
; EBP:EAX address to DAP LBA sector
push eax
mov eax, edx ; divide high dword first
xor edx, edx
div ebp
mov dword [si+8], eax
mov dword [si+12], 0
mov dword [si+12], eax
pop eax
div ebp ; divide low dword next along with remainder of high dword
mov dword [si+8], eax

pop dx

Expand All @@ -67,10 +73,8 @@ read_sectors:
jc .done

add word [si+4], bp
xor ebx, ebx
inc dword [si+8]
seto bl
add dword [si+12], ebx
add dword [si+8], 1
adc dword [si+12], 0

loop .loop

Expand Down
Loading