Two9A / jsGB

JavaScript emulation of the GameBoy console
http://imrannazar.com/
Other
726 stars 110 forks source link

Op LDmmSP isn't implemented #6

Open elvishfiend opened 7 years ago

elvishfiend commented 7 years ago

LDmmSP appears in _map but doesn't appear to be implemented anywhere.

Ayymoose commented 6 years ago

Yeah I noticed this too. According to a manual for the gameboy, it just loads a 16-bit address to the stack pointer.

Akhil841 commented 2 years ago

It actually writes the value of the stack pointer to a memory address and the location that follows, with the first memory address being passed as an imm16.

For more information, see Game Boy Opcode Periodic Table The Pan Docs

I'll include the pseudocode for my implementation here, for anyone who's reading this issue and is stumped on how to implement it, like I was.

pseudocode (C++):

void STR_IMM16_SP()
{
    unsigned short value = mmu.rw(pc);
    mmu.ww(value, sp);
    pc += 2;
    m = 5;
}