well lately I have been working on a CPU core for 6502 assembly, and I have been writing it all in c++. However for obvious reasons I was thinking of remaking the core in assembly. First I was wondering if it would be worth it (speed wise) to write functions in asm (inline?) and then call them in c++? or would there be another way to integrate an assembly to c++ that can tell assembly to run through certain stuff, yet still have access to the rest of the parts of the CPU the core is emulating (flags, registers, memory, etc)
right now when i do stuff like
// addrmode() points to the addressing mode per opcode
// m_A is the accumulator
// m_S is the processor status register
// bits- 1 - zero - first if statement
// 7 - signed - second if statement
void core6502::AND()
{
(this->*addrmode[m_opcode])();
m_A = m_value; // this value was obtained by addrmode() above
if(m_A)
m_S &= 0xFD;
else
m_S |= 0x02;
if(a & 0x80)
m_S |= 0x80;
else
m_S = 0x7F;
}
this is generally what my code looks like for each command, i tried to keep them all void because this function is actually just pointed to in many diferent cases, and addrmode points to one of the addressing functions so i dont have to write a different function for each opcodes addressing modes. Anyways would it truly be worth it to rewrite the asm? Because when I look at it, I couldn't imagine it would be much different either way
Also if inline is the way to go, any good resources on that heh. Like what registers am I free to use? Or can I use them and just restore later?