-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisk.asm
More file actions
49 lines (45 loc) · 678 Bytes
/
disk.asm
File metadata and controls
49 lines (45 loc) · 678 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
[bits 16]
lba_to_chs:
xor dx, dx
div word [SectorsPerTrack]
inc dl
mov cl, dl
xor dx, dx
div word [HeadsPerCylinder]
mov ch, al
mov dh, dl
ret
disk_read:
pusha
mov di, 3
.retry:
pusha
call lba_to_chs
mov ah, 0x02
mov al, cl
mov dl, [DriveNumber]
int 0x13
jnc .success
popa
call disk_reset
dec di
jnz .retry
jmp disk_error
.success:
popa
popa
ret
disk_reset:
pusha
mov ah, 0x00
mov dl, [DriveNumber]
int 0x13
jc disk_error
popa
ret
disk_error:
mov si, error_msg
call print_string
cli
hlt
error_msg db "Disk error!", 0xD, 0xA, 0