summaryrefslogtreecommitdiff
path: root/cpu.ha
diff options
context:
space:
mode:
authorubq323 <ubq323@ubq323.website>2024-05-02 23:43:33 +0100
committerubq323 <ubq323@ubq323.website>2024-05-02 23:43:33 +0100
commit47f19a98300adebaf20cfc763c4cc5ad74b755d2 (patch)
treefc83eddb2dcf7a25cbd665de8a3d92b00a3bffff /cpu.ha
parenta71e6c729761d07c7bf189c057951440d1fe251f (diff)
even more thingsHEADtrunk
Diffstat (limited to 'cpu.ha')
-rw-r--r--cpu.ha13
1 files changed, 10 insertions, 3 deletions
diff --git a/cpu.ha b/cpu.ha
index 3ffea05..7c23714 100644
--- a/cpu.ha
+++ b/cpu.ha
@@ -110,15 +110,22 @@ fn mainloop(cpu: *cpu) void = {
};
export fn main() void = {
+ if (len(os::args) != 2)
+ fmt::fatalf("usage: {} FILE.r1b", os::args[0]);
+ const fname = os::args[1];
+
const cpu = cpu_new();
- const fp = match (os::open("sys0.r1b")) {
+ const fp = match (os::open(fname)) {
case let i: io::file => yield i;
- case let e: fs::error => fmt::fatalf("MISSING BOOT SECTOR: {}",
+ case let e: fs::error => fmt::fatalf("couldn't open boot sector {}",
fs::strerror(e));
};
match (io::readall(fp, cpu.mem[0x0200..0x0300])) {
- case let e: io::error => fmt::fatalf("BOOT SECTOR READ ERROR: {}", io::strerror(e));
+ case let e: io::error => match (e) {
+ case io::underread => yield;
+ case let e: io::error => fmt::fatalf("couldn't read boot sector {}", io::strerror(e));
+ };
case => yield;
};