CPU::Emulator::6502::Op::INC - Increment by one


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

Index


Code Index:

NAME

Top

CPU::Emulator::6502::Op::INC - Increment by one

SYNOPSIS

Top

DESCRIPTION

Top

METHODS

Top

inc( $addr )

Increments the value at $addr by 1.

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::INC;

use strict;
use warnings;

use constant INSTRUCTIONS => {
    0xE6 => {
        addressing => 'zero_page',
        cycles => 5,
        code => \&inc,
    },
    0xF6 => {
        addressing => 'zero_page_x',
        cycles => 6,
        code => \&inc,
    },
    0xEE => {
        addressing => 'absolute',
        cycles => 6,
        code => \&inc,
    },
    0xFE => {
        addressing => 'absolute_x',
        cycles => 7,
        code => \&inc,
    },
};

sub inc {
    my $self = shift;
    my $reg  = $self->registers;

    my $temp = $self->memory->[ shift ];
    $temp++;
    $self->RAM_write( $temp );
    $self->set_nz( $temp );
}

1;