/[VRac]/M6502/t/05-M6502.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /M6502/t/05-M6502.t

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 194 by dpavlin, Thu Aug 2 12:53:00 2007 UTC revision 195 by dpavlin, Sun Apr 13 00:32:39 2008 UTC
# Line 6  use strict; Line 6  use strict;
6  use blib;  use blib;
7  use lib './lib';  use lib './lib';
8    
9  use Test::More tests => 54;  use Test::More tests => 92;
10  use Test::Exception;  use Test::Exception;
11  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
12    
# Line 65  foreach my $byte ( 0x00, 0x01, 0xff, 0xa Line 65  foreach my $byte ( 0x00, 0x01, 0xff, 0xa
65          cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' );          cmp_ok( M6502::_read($a), '==', $byte, 'M6502::_read' );
66  }  }
67    
 $mem[$_] = 0b11101101 foreach ( 0x6000 .. 0x7ffff );  
   
68  # flip bytes 6502 asm  # flip bytes 6502 asm
69  my $a = 0x1000;  my $a = 0x1000;
70    
# Line 80  $mem[$a++] = $_ foreach ( Line 78  $mem[$a++] = $_ foreach (
78          0xd9, 0x60, 0x00,          0xd9, 0x60, 0x00,
79  );  );
80    
81  diag dump_R();  my @flip_tests = (
82  $PC = 0x1000;          { fill => 0b11101101, expect => 0b10110111 },
83            { fill => 0b11101101, expect => 0b10110111, disable_all_callbacks => 1 },
84            { fill => 0b11110000, expect => 0b00001111, disable_all_callbacks => 1 }
85    );
86    
87    foreach my $test ( @flip_tests ) {
88    
89            diag "test ",dump( $test );
90    
91            is( M6502::disable_all_callbacks(), 0x11, 'disable_all_callbacks' ) if $test->{disable_all_callbacks};
92    
93            $mem[$_] = $test->{fill} foreach ( 0x6000 .. 0x7ffff );
94    
95            diag dump_R();
96            $PC = 0x1000;
97    
98  ok( my $left = M6502::exec( 1 ), 'M6502::exec(1)' );          ok( my $left = M6502::exec( 1 ), 'M6502::exec(1)' );
99  cmp_ok( $PC, '==', 0x1002, 'PC moved' );          cmp_ok( $PC, '==', 0x1002, 'PC moved' );
100  cmp_ok( $left, '==', -1, 'no cycles left' );          cmp_ok( $left, '==', -1, 'no cycles left' );
101    
102  ok( ! M6502::exec( 1000 ), 'M6502::exec' );          ok( ! M6502::exec( 1000 ), 'M6502::exec' );
103  cmp_ok( $PC, '==', 0x1016, 'PC moved' );          cmp_ok( $PC, '==', 0x1016, 'PC moved' );
104    
105  foreach my $a ( 0x6000 .. 0x600c ) {          foreach my $a ( 0x6000 .. 0x600c ) {
106          cmp_ok( $mem[$a], '==', 0b10110111, sprintf('flipped %04x',$a) );                  cmp_ok( $mem[$a], '==', $test->{expect}, sprintf('flipped %04x to %08b',$a, $mem[$a]) );
107            }
108  }  }

Legend:
Removed from v.194  
changed lines
  Added in v.195

  ViewVC Help
Powered by ViewVC 1.1.26