Execute Computer/Zero: Difference between revisions

Content added Content deleted
m (change debugging display)
Line 202: Line 202:
while compzero.isready
while compzero.isready
instruction = compzero.ram[compzero.ip]
instruction = compzero.ram[compzero.ip]
opcode = instruction >> 5 + 1
opcode, operand = instruction >> 5 + 1, instruction & 0b00011111
debug && println("op ", instructions[opcode])
debug && println("op $(instructions[opcode]), operand $operand")
step[opcode](compzero)
step[opcode](compzero)
opcode == 8 && break
end
end
return compzero.accum
end
end
run(program::Vector) = run(ComputerZero(program))
run(program::Vector, debug = false) = run(ComputerZero(program), debug)


function compile(text::String)
function compile(text::String)
Line 223: Line 223:
push!(bin, parse(UInt8, m.match))
push!(bin, parse(UInt8, m.match))
else
else
error("Compilation error in at line $lines: error parsing <$line>")
error("Compilation error at line $lines: error parsing <$line>")
end
end
end
end