David Cantrell > CPU-Emulator-Z80 > CPU::Emulator::Z80::ALU

Download:
CPU-Emulator-Z80-1.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

CPU::Emulator::Z80::ALU

DESCRIPTION ^

This mix-in provides functions for addition and subtraction on a Z80, settings flags and doing twos-complement jibber-jabber.

FUNCTIONS ^

All functions are exported. They all take a reference to the Flags register as the first parameter in addition to the parameters listed, unless otherwise stated:

ALU_add8/ALU_add16

Takes two 8/16-bit values and returns their 8/16-bit sum, and for add16, a third parameter indicating whether this was really called as ADC.

add16 doesn't frob the S, Z or P flags unless that extra parameter is true.

ALU_sub8/ALU_sub16

Takes two 8/16-bit values and subtracts the second from the first, returning the result.

ALU_inc8/ALU_dec8

Take a single 8-bit value and incremement/decrement it, returning the result. They're just wrappers around add8/sub8 that preserve the C flag.

ALU_parity

Returns the parity of its operand. No flags register is passed, as this does *not* update the register.

ALU_getsigned

Takes two parameters, a value and a number of bits. Decodes the value 2s-complement-ly for the appropriate number of bits, returning a signed value. undef is turned into 0.

No flags reigster needed

BUGS/WARNINGS/LIMITATIONS ^

None known

FEEDBACK ^

I welcome feedback about my code, including constructive criticism and bug reports. The best bug reports include files that I can add to the test suite, which fail with the current code in CVS and will pass once I've fixed the bug.

Feature requests are far more likely to get implemented if you submit a patch yourself.

CVS ^

http://drhyde.cvs.sourceforge.net/drhyde/perlmodules/CPU-Emulator-Z80/

AUTHOR, COPYRIGHT and LICENCE ^

Copyright 2008 David Cantrell <david@cantrell.org.uk>

This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.

CONSPIRACY ^

This module is also free-as-in-mason software.

syntax highlighting: