To add new cpu opcodes we need only to change two files: simulate.h and simulate.c
So we have to proceed with these steps:
Open this file and go down at line under the comment //New Opcodes and add your new opcode ABC as last and before the end_ops constant.
For example:
//New Opcodes
MDIV , // MDIV R, 10, M : (S>D) -- Calc Modulus and Division putting them into destination Registers
STX , // STX 0xFF , M : (S>D) -- Store immed. value into contents of [MemoryAddress] pointed by Register
+ ABC , // short description
Open this file and go at line 325 under the comment //New Opcodes and add your macro that represent the opcode ABC.
You may need study other opcodes to understand how they work, it's not too difficult...
For example:
#define ABC_opcode _cpuREG( cpuIMM_ARG(1) ) = cpuIMM_ARG(2); \
currPC += value // size of this intruction
(**notice: this opcode is equivalent to: SET R, VALUE)
Go at line 482 of this file under the comment //New Opcodes and add your macro that represent the opcode ABC
__def_opcall( ABC );
Go at line 569 of this file under the comment //New Opcodes and add your initialisation group that represent the opcode ABC
{ __Opcode_Struct( ABC , 3 , "#RI" ) },
Go at line 730 inside the simugoto() routine and add your goto-constant after the last constants :
&&do_MDIV, &&do_STX, &&do_ABC, // new opcodes
Go at line 858 inside the simugoto() routine and add your label definition where the simulator will jump in:
__def_goto_Label( ABC );
STOP.
You don't needs to do any other steps!!
In alternative to the simugoto() routine, there is another equivalent routine called simulate():
if you use this routine you don't need to do the steps 730/858 which are exclusive for simugoto() routine.
Well, that's all for now.
I greet you and thank you.
Anonymous