I am developing a small virtual machine in C ++ for a school project that should work as a dc command and consists of an Input Output element, a chipset, a processor, and a Ram. I am currently working on a chipset in which I implemented a small parsing class to be able to retrieve ASM instructions from standard input or a file and then push these instructions onto the CPU.
The problem is that my instructions are sorted into std :: list, and I would like each of them to be able to click on the foreach command on them. To do this, I need to be able to call my member function "push_instruction" as a pointer to the F for_each function; and I could not find a trick to do this ...
Any ideas? here is my code:
void Chipset::startExecution()
{
for_each(this->_instructList.begin(), this->_instructList.end(), this->pushInstruction);
}
void Chipset::pushInstruction(instructionList* instruction)
{
if (instruction->opCode == PUSH)
this->_processor->pushOperand(instruction->value, Memory::OPERAND, Memory::BACK);
else if (instruction->opCode == ASSERT)
this->_processor->pushOperand(instruction->value, Memory::ASSERT, Memory::BACK);
else
this->_processor->pushOperation(instruction->opCode);
}