diff options
Diffstat (limited to 'cpu.ha')
-rw-r--r-- | cpu.ha | 13 |
1 files changed, 10 insertions, 3 deletions
@@ -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; }; |