Class BCD

java.lang.Object
  extended by BCD

public final class BCD
extends java.lang.Object

SBCD and NBCD both involve the subtraction operation. So, this class was created to: (1) isolate the BCD computations and, (2) prevent code replication in the case of BCD subtraction. Both SBCD and NBCD call BCDSUB().

[MOTUM] MC68000 MC68008 MC68010 MC68HC000 8-/16-/32-Bit Microprocessors User's Manual Seventh Edition", M68000UM/AD Rev 6, Motorola, published by Prentice Hall. Note: This book is copyright Motorola. It was previously published under the title: "M68000 8-/16-/32-bit Microprocessor Programmer's Reference Manual".


Method Summary
static VCbits bcdadd(Reg8 S, Reg8 D, boolean Xin)
          Adds the binary coded decimal values S and D together along with the carry in bit Xin and returns the resulting sum, V, and C bits in an object of type VCbits.
static VCbits bcdsub(Reg8 S, Reg8 D, boolean Xin)
          Subtracts the binary coded decimal (BCD) value (S + Xin) from the destination BCD value D and returns the resulting difference, V, and C bits in an object of type VCbits.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

bcdadd

public static VCbits bcdadd(Reg8 S,
                            Reg8 D,
                            boolean Xin)
Adds the binary coded decimal values S and D together along with the carry in bit Xin and returns the resulting sum, V, and C bits in an object of type VCbits. The V and C condition code register bits are set according to the result and are returned. [MOTUM] states that the V return bit is "Undefined" but this function sets it to false. This function does NOT assume that S and D are valid packed BCD numbers because a real MC68000 does not make this assumption. This was verified on a Mac Classic. In other words, a Mac Classic will not cause a fault if you pass ABCD a backed BCD number with non-decimal digits (e.g., "A").


bcdsub

public static VCbits bcdsub(Reg8 S,
                            Reg8 D,
                            boolean Xin)
Subtracts the binary coded decimal (BCD) value (S + Xin) from the destination BCD value D and returns the resulting difference, V, and C bits in an object of type VCbits. The V and C condition code register bits are set according to the result and are returned. [MOTUM] states that the V return bit is "Undefined" but this function sets it to false. This function does NOT assume that S and D are valid packed BCD numbers because a real MC68000 does not make this assumption. This was verified on a Mac Classic. In other words, a Mac Classic will not cause a fault if you pass SBCD a backed BCD number with non-decimal digits (e.g., "A").