It is currently Tue Dec 12, 2017 2:59 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Emulator CPU tests
PostPosted: Sat Jan 15, 2011 5:30 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
I've recently started my own GB emulator and I'm currently trying to nail down the CPU.

I'm using Blaarg's cpu instructions test from this thread and I've got some that come back as passed but others that are failing, I'm not sure how to interpret the output of the failed tests to try and see where I'm going wrong.

The multi test craps out on test 4:

Code:
cpu_instrs

01:ok  02:ok  03:01  04:01 

Failed 2 tests.


It's test 3 and 4 I'm not sure where to start with, the output from them is:

Test 03:
Code:
03-op sp,hl

09
Failed


Test 04:
Code:
04-op r,imm

0E 0E
Failed


I'm not sure what the error codes printed from these individual tests mean.

Any clues as to where to start appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 6:51 am 
Offline
User avatar

Joined: Fri Nov 19, 2004 7:35 pm
Posts: 3968
Is it the flags register (F) output of what those instructions do? I think the hl,sp instructions did unexpected things to compute the flags. Maybe read the source code to Gambatte's CPU core, and see what it does.

_________________
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 7:36 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
Do you mean that the 09 and 0E 0E have something to do with the flags?

I've been through my instructions and compared to the gb programming reference I have and I think the instructions are doing as they should and setting/resetting the right flags.

I was hoping the number output would help me try and identify which instruction the test says is failing.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 9:19 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
Ok, I fixed test 3 and got that passing now.

I wasn't calculating the H flag correctly in my 16 bit add. 09 was in fact ADD HL, BC.

I don't understand the error for test 4 though as 0E is LD C,n and I can't see any problems with that, it's just doing what all the other immediate loads are doing.

Anyone know what the 0E 0E from test 4 means.

The other question is that when I run the test in other emulators it goes through more tests but I only have it run the 4 then fail. Is it because the other tests rely on something that the first 4 test so bail out at the point?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 9:32 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
Well are you sure 0E is the opcode? It might be something else, like an index into the table of values that it's testing the instructions with.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 9:39 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
mic_ wrote:
Well are you sure 0E is the opcode? It might be something else, like an index into the table of values that it's testing the instructions with.

No :)

That's where I'm unsure, don't know if it's the opcode or an index into the table etc.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 10:55 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
I think I have narrowed it down to my SBC opcode and the H flag.

What should be happening to the H flag during SBC?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 15, 2011 11:08 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
IIRC, it should be set for SBC if the low 4 bits of the second operand (including the carry) are greater than the low 4 bits of the first operand.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 16, 2011 4:36 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
mic_ wrote:
IIRC, it should be set for SBC if the low 4 bits of the second operand (including the carry) are greater than the low 4 bits of the first operand.

Thanks.

After fixing that and some of my shifts and rotates I now get the following:

Code:
cpu_instrs

01:ok  02:ok  03:ok  04:ok 

Passed all tests


:)

Not sure why I'm only getting 4 tests run though. If I run the test on another emulator I see it run 11 tests. Would it be dependent on some features I'm missing? I've run all these tests so far before doing any LCD emulation, the output I'm getting from the serial IO.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 16, 2011 10:10 am 
Offline

Joined: Thu Jul 29, 2010 4:39 am
Posts: 24
OK, after playing a game of spot the muppet and fixing my ROM banking I'm there:

Code:
cpu_instrs

01:ok  02:ok  03:ok  04:ok  05:ok  06:ok  07:ok  08:ok  09:ok  10:ok  11:ok 

Passed all tests


:)

Now onto the next bits.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 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