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
|
fn load-sectors disk: (addr disk), lba: int, n: int, out: (addr stream byte) {
var curr-lba/ebx: int <- copy lba
var remaining/edx: int <- copy n
{
compare remaining, 0
break-if-<=
# sectors = min(remaining, 0x100)
var sectors/eax: int <- copy remaining
compare sectors, 0x100
{
break-if-<=
sectors <- copy 0x100
}
#
read-ata-disk disk, curr-lba, sectors, out
#
remaining <- subtract sectors
curr-lba <- add sectors
loop
}
}
fn store-sectors disk: (addr disk), lba: int, n: int, in: (addr stream byte) {
var curr-lba/ebx: int <- copy lba
var remaining/edx: int <- copy n
{
compare remaining, 0
break-if-<=
# sectors = min(remaining, 0x100)
var sectors/eax: int <- copy remaining
compare sectors, 0x100
{
break-if-<=
sectors <- copy 0x100
}
#
write-ata-disk disk, curr-lba, sectors, in
#
remaining <- subtract sectors
curr-lba <- add sectors
loop
}
}
|