Soul of a tiny new machine. More thorough tests → More comprehensible and rewrite-friendly software → More resilient society.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

43 lines
995 B

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
}
}