Skip to content

Instantly share code, notes, and snippets.

@lispandfound
Created May 10, 2019 08:30
Show Gist options
  • Save lispandfound/04425e4a05dbf59f5810579e47dc223e to your computer and use it in GitHub Desktop.
Save lispandfound/04425e4a05dbf59f5810579e47dc223e to your computer and use it in GitHub Desktop.
program := 0;
i := 0;
read program;
read i;
j := i;
l := 0;
data := 0;
while j >= 0 do
pow := 1;
k := 0;
while k < j do
pow := pow * 16;
k := k + 1
end;
instruction := program / pow;
instruction := instruction - 8*(instruction / 8);
m := 0;
dpow := 1;
while m < l do
dpow := dpow * 256;
m := m + 1
end;
cdata := data / dpow;
cdata := cdata - 256*(cdata /256);
if instruction = 0 then
l := l + 1
else if instruction = 1 then
l := l - 1
else if instruction = 2 then
if cdata = 255 then
data := data - 255 * dpow
else
data := data + dpow
end
else if instruction = 3 then
if cdata = 0 then
data := data + 255 * dpow
else
data := data - dpow
end
else if instruction = 4 then
write cdata
else if instruction = 5 then
in := 0;
read in;
data := data - cdata*dpow;
data := data + in*dpow
else if instruction = 6 then
if cdata = 0 then
p := 1;
while p > 0 do
j := j - 1;
pow := pow / 16;
cinstr := program / pow;
cinstr := cinstr - 8*(cinstr / 8);
if cinstr = 6 then
p := p + 1
else if cinstr = 7 then
p := p - 1
end
end
end
end
else if instruction = 7 then
loop := 1;
while loop > 0 do
j := j + 1;
pow := pow * 16;
cinstr := program / pow;
cinstr := cinstr - 8*(cinstr / 8);
if cinstr = 7 then
loop := loop + 1
else if cinstr = 6 then
loop := loop - 1
end
end
end;
j := j + 1
end
end
end
end
end
end
end
end;
j := j - 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment