-
Notifications
You must be signed in to change notification settings - Fork 241
Open
Description
Per: http://www.obelisk.me.uk/6502/reference.html#TSX
C = the contents of the old bit 7
While the provided code does this, to someone newer at this kind of thing, it looks like it doesn't
I'd recommend changing the implementation to the following:
uint8_t olc6502::ASL()
{
fetch();
SetFlag(C, (fetched & 0x80)); //this will return either a 1 or a 0, so we don't need > 0 here
fetched = (uint8_t)(fetched << 1); //could also be replaced with fetched *= 2. the cast is to prevent the possibility of the compiler upgrading fetched to uint16_t)
SetFlag(Z, (fetched & 0xFF) == 0x00);
SetFlag(N, fetched & 0x80); //funnily enough, this is the same code we use to initially set the carry flag since bit 7 is the sign
if (lookup[opcode].addrmode == &olc6502::IMP)
a = fetched;
else
write(addr_abs, fetched);
return 0;
}This is pretty much my implementation of this opcode, and I was checking against the source code provided and initially thought I was doing something wrong (even though I'm not newer to this, I've written a full CHIP 8 emulator and done some other things using binary for a private server project). It took longer than I'd like to admit to realise that the code provided does the same thing, it just does some extra things that could be removed (yay optimization).
brccabral
Metadata
Metadata
Assignees
Labels
No labels