Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
46 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters