Data update
This commit is contained in:
parent
35bcdeebf8
commit
74c69a0df6
2427 changed files with 31826 additions and 3468 deletions
38
Task/Subleq/SETL/subleq.setl
Normal file
38
Task/Subleq/SETL/subleq.setl
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
program subleq;
|
||||
if command_line(1) = om then
|
||||
print("error: no file given");
|
||||
stop;
|
||||
end if;
|
||||
|
||||
mem := readprog(command_line(1));
|
||||
|
||||
loop init ip := 0; while ip >= 0 do
|
||||
a := mem(ip) ? 0;
|
||||
b := mem(ip+1) ? 0;
|
||||
c := mem(ip+2) ? 0;
|
||||
ip +:= 3;
|
||||
if a = -1 then
|
||||
mem(b) := ichar (getchar ? "\0");
|
||||
elseif b = -1 then
|
||||
putchar(char ((mem(a) ? 0) mod 256));
|
||||
elseif (mem(b) +:= -(mem(a) ? 0)) <= 0 then
|
||||
ip := c;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
proc readprog(fname);
|
||||
if (f := open(fname, "r")) = om then
|
||||
print("error: cannot open file");
|
||||
stop;
|
||||
end if;
|
||||
|
||||
mem := {};
|
||||
mp := 0;
|
||||
loop doing getb(f, n); while n/=om do
|
||||
mem(mp) := n;
|
||||
mp +:= 1;
|
||||
end loop;
|
||||
close(f);
|
||||
return mem;
|
||||
end proc;
|
||||
end program;
|
||||
Loading…
Add table
Add a link
Reference in a new issue