It is currently Thu Sep 20, 2018 5:18 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Fri Aug 31, 2018 6:41 pm 
Offline
User avatar

Joined: Sun Sep 07, 2008 7:27 am
Posts: 494
Location: Seatlle, WA, USA
Hello,

My 6502 CPU core 100% passes all of the CPU opcode test from kevtris' nestest.nes [1], but fails all sbc opcode tests (and others) in blargg's nes_instr_test (nes_instr_test/rom_singles/03-zero_page.nes) [2]. Both test suites pass on FCEUX (v2.2.3 under wine on Linux).

I obtained nestest.nes from [3] on 2017-08-22, and the nes_instr_test roms from cpow's github [4] recently.

This is my SBC implementation:

Code:
void Cpu::op_sbc(uint8_t data)
{
  uint16_t t = m_regs.a - data - !m_regs.flag_c;
  m_regs.flag_c = !(t & 0x100);
  m_regs.flag_v = (m_regs.a ^ t) & (~data ^ t) & 0x80;
  m_regs.flag_z = !t;
  m_regs.flag_n = t & 0x80;
  m_regs.a = t;
}


is "nestest.nes" considered accurate? Which test suite is the "gold standard" that I should use to verify my emulator?

[1] md5 = 4068f00f3db2fe783e437681fa6b419a
[2] md5 = 67c242cd4954a37f3bfe6c90e887fbd5
[3] http://nickmass.com/images/nestest.nes
[4] https://github.com/christopherpow/nes-test-roms


Top
 Profile  
 
PostPosted: Fri Aug 31, 2018 7:26 pm 
Offline
User avatar

Joined: Sun Sep 07, 2008 7:27 am
Posts: 494
Location: Seatlle, WA, USA
I've replaced my implementation of "op_sbc(data)" with "op_adc(data ^ 0xff)" and now both test suites pass.


Top
 Profile  
 
PostPosted: Fri Aug 31, 2018 8:28 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3597
Location: Mountain View, CA
Mainly for future readers:

ADC/SBC implementations (and code) covered here: viewtopic.php?p=19080#19080

Blargg's post is correct (very similar to yours), as is Disch's post.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group