From 8a3ba59193b0487fdffa4dc05abd4487b1ebf7fb Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Wed, 1 Mar 2017 18:05:08 +0100 Subject: Fix jump parsing bug (and better debug logging) --- main.cpp | 2 +- world.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main.cpp b/main.cpp index a4c8714..20eb1fe 100644 --- a/main.cpp +++ b/main.cpp @@ -76,7 +76,7 @@ Argument parseArgument(const string &str,const unordered_map &l } Location ref=labels.find(str.substr(1))->second; assert(ref.bank==ip.bank); - return {arg_t::number,false,ref.bank-ip.bank,{}}; + return {arg_t::number,false,ref.pos-ip.pos,{}}; } else if(str[0]=='$'){ return {arg_t::constant,false,0,str.substr(1)}; } else if(isdigit(str[0])){ diff --git a/world.cpp b/world.cpp index 982b2cd..2ca362e 100644 --- a/world.cpp +++ b/world.cpp @@ -29,7 +29,7 @@ WorldAction Robot::tick(World &world){ } uint16_t* Robot::resolveVar(const Argument &arg,World &world){ - cout<<"resolveVar("<<(int)arg.type<<","< dstvar(ins.args.size(),false); if(ins.op==ins_t::set||ins.op==ins_t::add||ins.op==ins_t::sub||ins.op==ins_t::scan){ assert(dstvar.size()>0); @@ -112,7 +112,7 @@ int Robot::calcDuration(Instruction &ins){ } WorldAction Robot::execute(Instruction &ins,World &world){ - cout<<"Executing "<