Hello,
The first minicpu I tried had many drawbacks... but maybe also some
adventages... but for a moving warrior the minicpu is unusuable... because
the real instruction pointer always moves forward by 1, and the warrior
moves forward by 1 so this cancels out each other... and the warrior will
always execute the same instruction over and over again... this could be
nice... but it would also be nice if a moving warrior can have a mini cpu
embedded so that it can even have normal program flow while it moves !
And for that to work it must have a good functioning cpu ! =D
However writing a fully functionaly cpu might require lot's of working and
maybe even lot's of instructions... but for those that dare to write one
here are some little hints to help you out, here goes:
1. Consider the program to be executed to be main memory.
2. Consider the minicpu to have it's own local memory.
3. The minicpu should load instructions from main memory, into it's local
memory.
4. The minicpu should execute the instruction located inside it's local
memory.
Thus some easy concepts:
The minicpu should have:
1. An instruction pointer which it can increment, decrement, add, subtract.
2. An instruction register where instructions from main memory, via the
instruction pointer, will be loaded to.
3. The cpu should execute the instruction which is loaded inside the
instruction register.
There are more difficulties to overcome:
The cpu should not execute jump statements. Instead the cpu should add the
jump parameter to the instruction pointer.
And then there are other problems like addressing modes.
In short it might be quite a task to write a good functioning mini cpu
inside redcode !
Sigh.. I might try to write a minicpu myself... if anyone already wrote
one... please share that will save me some time
There go folks ! Some hints for ya ! =D
Bye,
Skybuck.