Colonel Kernel wrote:This is why macros are EVIL.
Bad programming is EVIL, that's why you should always use { and } after an if statement, then these problems don't happen. I love macro's, they make life easy
. You don't even want to see some of my source code for my virtual machine, lol, the entire thing is almost made of macro's. Very confusing to anybody trying to write software for it, but makes it very easy to add opcodes
. For things to do with math, I just call
#define ADD +=
#define SUB -=
#define INC ++
#define DEC --
#define MATH(r1,r2,func)\
r1 func r2;\
SetFlags(r1);
#define OpCode(OpType,Func,Reg1,Reg2,Index)\
case Index:\
OpType(Reg1,Reg2,Func)\
break;
switch (Program[PC])
{
OpCode(MATH,ADD,REGINT1,REGINT2,0x01);
OpCode(MATH,SUB,REGINT1,REGINT2,0x02);
OpCode(MATH,INC,REGINT1,,0x03);
OpCode(MATH,DEC,REGINT1,,0x04);
};
This is pretty much how the entire things runs
. Everything is inline, it's very simple to expand for me, and it is entirely macro driven.