import "io" let buffer = vec(128); let pos = 0; let writechar(c) be { if pos >= 512 then { devctl(DC_TAPE_WRITE, 1, buffer, 512); pos := 0 } byte pos of buffer := c; pos +:= 1 } let writestring(s) be { let i = 0; while true do { let c = byte i of s; if c = 0 then break; writechar(c); i +:= 1 } } let writeno(n) be { if n > 9 then writeno(n / 10); writechar(n rem 10 + '0') } let wopen(name) be { let r = devctl(DC_TAPE_LOAD, 1, name, 'W'); if r < 0 then { out("error %d for load\n", r); finish } } let wclose() be { if pos > 0 then devctl(DC_TAPE_WRITE, 1, buffer, pos); devctl(DC_TAPE_UNLOAD, 1) } let start() be { wopen("data.txt"); for c = 0 to 100 do { let f = c * 9 / 5 + 32; writeno(c); writestring(" centigrade is "); writeno(f); writestring(" fahrenheit\n") } wclose() }