From 47f19a98300adebaf20cfc763c4cc5ad74b755d2 Mon Sep 17 00:00:00 2001 From: ubq323 Date: Thu, 2 May 2024 23:43:33 +0100 Subject: even more things --- cpu.ha | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'cpu.ha') 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; }; -- cgit v1.2.3