aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomsmeding <tom.smeding@gmail.com>2017-03-20 23:20:00 +0100
committertomsmeding <tom.smeding@gmail.com>2017-03-21 22:49:30 +0100
commit7c437e1e39f73517b458aa72f9754e165f572969 (patch)
tree1ed52f6fd8fd87fb70daf2fe6b0b14d7878ee90c
parent32c25651f707b13f5f0c27cf807521cf163dcacb (diff)
Add debugger instruction (int3)
Just compiles to an 'int3' instruction; not a full-featured debugger...
-rw-r--r--params.cpp1
-rw-r--r--params.h1
-rw-r--r--parse.cpp5
-rw-r--r--world.cpp5
4 files changed, 10 insertions, 2 deletions
diff --git a/params.cpp b/params.cpp
index 5b71e86..3cdc210 100644
--- a/params.cpp
+++ b/params.cpp
@@ -18,6 +18,7 @@ namespace C {
8, // turn
8, // scan
100, // create
+ 1, // debugger
};
const int numInstructions=(int)ins_t::__num_instructions;
diff --git a/params.h b/params.h
index 175db2f..f3053dc 100644
--- a/params.h
+++ b/params.h
@@ -15,6 +15,7 @@ enum class ins_t{
turn, // $dir
scan, // #dst
create, // $is, $nbanks, $move
+ debugger, // -
__num_instructions
};
diff --git a/parse.cpp b/parse.cpp
index cbfb306..8c1a21e 100644
--- a/parse.cpp
+++ b/parse.cpp
@@ -109,8 +109,8 @@ Team assemble(const string &source){
pargs.push_back(parseArgument(s,labels,
{(int)team.banks.size()-1,(int)team.banks.back().size()}));
}
- if(word1=="jump"||word1=="turn"||word1=="scan")assert(pargs.size()==1);
- else if(word1=="die"||word1=="move")assert(pargs.size()==0);
+ if(word1=="debugger"||word1=="die"||word1=="move")assert(pargs.size()==0);
+ else if(word1=="jump"||word1=="turn"||word1=="scan")assert(pargs.size()==1);
else if(word1=="create")assert(pargs.size()==3);
else assert(pargs.size()==2);
@@ -127,6 +127,7 @@ Team assemble(const string &source){
else if(word1=="turn")s.push_back(Instruction::make(ins_t::turn,{pargs[0]}));
else if(word1=="scan")s.push_back(Instruction::make(ins_t::scan,{pargs[0]}));
else if(word1=="create")s.push_back(Instruction::make(ins_t::create,{pargs[0],pargs[1],pargs[2]}));
+ else if(word1=="debugger")s.push_back(Instruction::make(ins_t::debugger,{}));
else assert(false);
}
}
diff --git a/world.cpp b/world.cpp
index 7b2d565..0a3c2ff 100644
--- a/world.cpp
+++ b/world.cpp
@@ -118,6 +118,7 @@ int Robot::calcDuration(Instruction &ins){
case ins_t::turn: d+=base; break;
case ins_t::scan: d+=base; break;
case ins_t::create: d+=(base+C::pen_createbank*ins.args[1].num)*C::pen_createmobilemult+C::pen_createmobile*ins.args[2].num+C::pen_createiset1*(ins.args[0].num==1)+C::pen_createiset2*(ins.args[0].num==2); break;
+ case ins_t::debugger: d+=base; break;
default: assert(false);
}
return d;
@@ -209,6 +210,10 @@ WorldAction Robot::execute(Instruction &ins,World &world){
world.createInFront(this,this->team,ins.args[0].num,ins.args[1].num,ins.args[2].num);
break;
+ case ins_t::debugger:
+ __asm("int3\n\t");
+ break;
+
default:
assert(false);
}