| Games-NES-Emulator documentation | Contained in the Games-NES-Emulator distribution. |
CPU::Emulator::6502::Op::CPX - Compare the X register
Compares the X register to the data held at $addr.
Brian Cassidy <bricas@cpan.org>
Copyright 2007 by Brian Cassidy
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Games-NES-Emulator documentation | Contained in the Games-NES-Emulator distribution. |
package CPU::Emulator::6502::Op::CPX; use strict; use warnings; use constant INSTRUCTIONS => { 0xE0 => { addressing => 'immediate', cycles => 2, code => \&cpx }, 0xE4 => { addressing => 'zero_page', cycles => 3, code => \&cpx }, 0xEC => { addressing => 'absolute', cycles => 4, code => \&cpx } };
sub cpx { my $self = shift; my $reg = $self->registers; my $temp = $reg->{ x } - $self->memory->[ shift ]; $reg->{ status } &= CPU::Emulator::6502::CLEAR_SZC; $self->set_nz( $temp ); $reg->{ status } |= CPU::Emulator::6502::SET_CARRY if $temp < 0x100; }
1;