Skip to content

Commit 81bde9e

Browse files
authored
Merge pull request #552 from lukflug/no-llm
reimplement stage1 changes
2 parents fdba681 + 4313d46 commit 81bde9e

File tree

2 files changed

+26
-21
lines changed

2 files changed

+26
-21
lines changed

stage1/hdd/bootsect.asm

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ start:
7878
lgdt [gdt]
7979

8080
cli
81+
82+
push dword 0
83+
mov ebp, 0x10
84+
8185
mov eax, cr0
8286
bts ax, 0
8387
mov cr0, eax
@@ -114,17 +118,14 @@ err:
114118

115119
bits 32
116120
vector:
117-
mov eax, 0x10
118-
mov ds, ax
119-
mov es, ax
120-
mov fs, ax
121-
mov gs, ax
122-
mov ss, ax
121+
mov ds, ebp
122+
mov es, ebp
123+
mov fs, ebp
124+
mov gs, ebp
125+
mov ss, ebp
123126

124127
and edx, 0xff
125128

126-
push 0
127-
128129
push edx
129130

130131
push stage2.size

stage1/hdd/disk.asm

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,34 @@ read_sectors:
3434
mov si, .drive_params
3535
mov word [si], 30 ; buf_size
3636
int 0x13
37-
jc .done
38-
mov bp, word [si+24] ; bytes_per_sect
37+
pushf
38+
movzx ebp, word [si+24] ; bytes_per_sect
3939

4040
; ECX byte count to CX sector count
41-
mov ax, cx
42-
shr ecx, 16
43-
mov dx, cx
41+
mov eax, ecx
42+
xor edx, edx
43+
div ebp
4444
xor cx, cx
45-
div bp
4645
test dx, dx
4746
setnz cl
4847
add cx, ax
4948

49+
popf
5050
pop edx
5151
pop eax
5252

5353
pop si
54+
jc .done
5455

55-
; EBP:EAX address to EAX LBA sector
56+
; EBP:EAX address to DAP LBA sector
57+
push eax
58+
mov eax, edx ; divide high dword first
59+
xor edx, edx
5660
div ebp
57-
mov dword [si+8], eax
58-
mov dword [si+12], 0
61+
mov dword [si+12], eax
62+
pop eax
63+
div ebp ; divide low dword next along with remainder of high dword
64+
mov dword [si+8], eax
5965

6066
pop dx
6167

@@ -67,10 +73,8 @@ read_sectors:
6773
jc .done
6874

6975
add word [si+4], bp
70-
xor ebx, ebx
71-
inc dword [si+8]
72-
seto bl
73-
add dword [si+12], ebx
76+
add dword [si+8], 1
77+
adc dword [si+12], 0
7478

7579
loop .loop
7680

0 commit comments

Comments
 (0)