import "io" let buffer = vec(128); let pos = 0; let refill() be { let r = devctl(DC_TAPE_READ, 1, buffer); if r < 0 then { out("error %d from tape_read\n", r); finish } pos := 0 } let fgetc() be { let result; if pos >= 512 then refill(); result := byte pos of buffer; pos +:= 1; resultis result } let fopen(name) be { let r = devctl(DC_TAPE_LOAD, 1, name, 'R'); if r < 0 then { out("error %d for load\n", r); finish } } let fclose() be { devctl(DC_TAPE_UNLOAD, 1) } let start() be { fopen("numbers.txt"); while true do { let c = fgetc(); out("the character was %c\n", c) } fclose(); }