- AUTHOR, COPYRIGHT and LICENCE
This mix-in provides functions for addition and subtraction on a Z80, settings flags and doing twos-complement jibber-jabber.
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:
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.
Takes two 8/16-bit values and subtracts the second from the first, returning the result.
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.
Returns the parity of its operand. No flags register is passed, as this does *not* update the register.
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
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.
Copyright 2008 David Cantrell <firstname.lastname@example.org>
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.
This module is also free-as-in-mason software.