It is currently Sat Dec 15, 2018 11:16 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: CPU cycle count
PostPosted: Thu Jun 20, 2013 6:50 pm 
Offline

Joined: Thu Jun 20, 2013 3:54 pm
Posts: 2
Hi! I've started working on a NES emulator and I'm now testing the CPU.

I've run through nestest.nes and all instructions execute correctly. My problem is, the cycle count is way off right from the start.

These are the first 10 cycle counts from the start:

Code:
+------+-------------+-------------+
| Mine | Nestest.nes | Instruction |
+------+-------------+-------------+
|    0 |           0 | JMP $C5F5   |
|    5 |           9 | LDX #$00    |
|    7 |          15 | STX $00     |
|   10 |          24 | STX $10     |
|   13 |          33 | STX $11     |
|   16 |          42 | JSR $C72D   |
|   22 |          42 | NOP         |
|   24 |          60 | SEC         |
|   26 |          66 | BCS $C735   |
|   28 |          72 | NOP         |
+------+-------------+-------------+


I must be missing something fundamental, since it isn't even close to matching. I only increment the cycle counter after an instruction has been carried out.
Am I supposed to count cycles somewhere else? Right now only the CPU is implemented, nothing else.


Top
 Profile  
 
 Post subject: Re: CPU cycle count
PostPosted: Thu Jun 20, 2013 6:58 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20877
Location: NE Indiana, USA (NTSC)
Nintendulator, the emulator used to record the golden log you're probably looking at, counts PPU cycles. Three PPU cycles equal one CPU cycle (on NTSC and RGB systems). And why is JMP taking five cycles anyway?


Top
 Profile  
 
 Post subject: Re: CPU cycle count
PostPosted: Thu Jun 20, 2013 7:27 pm 
Offline

Joined: Thu Jun 20, 2013 3:54 pm
Posts: 2
Ah I see, thanks.

I mixed up the addressing modes on the JMP opcodes that's why it took five instead of three cycles.
One step closer to something now!


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: No registered users and 4 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