diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2021-07-16 08:58:15 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2021-07-16 08:58:15 -0700 |
commit | d771fb6babbaac4a2086e649e1645bc5760a0b98 (patch) | |
tree | 6d3b110d8e5d729b150ae1813a3a936dc59881a4 /510disk.mu | |
parent | 96c217ab1cbba92669e88ee9877d0fefc76d16c0 (diff) | |
download | mu-d771fb6babbaac4a2086e649e1645bc5760a0b98.tar.gz |
more powerful load-sectors
Diffstat (limited to '510disk.mu')
-rw-r--r-- | 510disk.mu | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/510disk.mu b/510disk.mu new file mode 100644 index 00000000..fd02bd4e --- /dev/null +++ b/510disk.mu @@ -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 + } +} |