CPU::Emulator::6502::Op::CPY - Compare the Y register


Games-NES-Emulator documentation Contained in the Games-NES-Emulator distribution.

Index


Code Index:

NAME

Top

CPU::Emulator::6502::Op::CPY - Compare the Y register

SYNOPSIS

Top

DESCRIPTION

Top

METHODS

Top

cpy( $addr )

Compares the Y register to the data held at $addr.

AUTHOR

Top

Brian Cassidy <bricas@cpan.org>

COPYRIGHT AND LICENSE

Top

SEE ALSO

Top

* CPU::Emulator::6502

Games-NES-Emulator documentation Contained in the Games-NES-Emulator distribution.
package CPU::Emulator::6502::Op::CPY;

use strict;
use warnings;

use constant INSTRUCTIONS => {
    0xC0 => {
        addressing => 'immediate',
        cycles => 2,
        code => \&cpy
    },
    0xC4 => {
        addressing => 'zero_page',
        cycles => 3,
        code => \&cpy
    },
    0xCC => {
        addressing => 'absolute',
        cycles => 4,
        code => \&cpy
    }
};

sub cpy {
    my $self = shift;
    my $reg = $self->registers;
    
    my $temp = $reg->{ y } - $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;