Since in the other emulators im not exactly seeing the ABCD instruction (probably because it was sort of embeded into the ADD instruction itself I'm assuming...at least in one of the emulators) we are going to skip that and focus on ADD. So according to the Motorola 68000 PDF documentation:
There are also multiple data types used for ADD such as Byte (8 bit), Short (16 Bit), as well as Integer (32 bit). 64 bit instructions are not supported. And according to one emulators I examined, there are 2 different versions of each. One version having condition code registers updated and the other not having condition code registers updated. For example, here is the C# version:Code:ADD (M68000 Family) Operation: Source + Destination→Destination Assembler: ADD < ea > ,Dn Syntax: ADD Dn, < ea > Attributes: Size = (Byte, Word, Long) Description: Adds the source operand to the destination operand using binary addition and stores the result in the destination location. The size of the operation may be specified as byte, word, or long. The mode of the instruction indicates which operand is the source and which is the destination, as well as the operand size. Condition Codes: X — Set the same as the carry bit. N — Set if the result is negative; cleared otherwise. Z — Set if the result is zero; cleared otherwise. V — Set if an overflow is generated; cleared otherwise. C — Set if a carry is generated; cleared otherwise. Instruction Format: X * N * Z * V * C * |15|14|13|12|11|10|09|08|07|06|05|04|03||02|01|00| | 1 | 1 | 0| 1 |REGISTER|OPMODE| MODE | REGISTER |
C# Code:
#region Add Helper Functions private sbyte Add(sbyte a, sbyte b, bool updateConditions, bool useX) { int result = useX ? (int)a + (int)b + (this.X ? 1 : 0) : (int)a + (int)b; if (updateConditions) { this.C = this.X = (result & 0x100) > 0; this.V = result > sbyte.MaxValue || result < sbyte.MinValue; this.N = result < 0; if (!useX) { this.Z = result == 0; } } return (sbyte)result; } private short Add(short a, short b, bool updateConditions, bool useX) { int result = useX ? (int)a + (int)b + (this.X ? 1 : 0) : (int)a + (int)b; if (updateConditions) { this.C = this.X = (result & 0x10000) > 0; this.V = result > short.MaxValue || result < short.MinValue; this.N = result < 0; if (!useX) { this.Z = result == 0; } } return (short)result; } private int Add(int a, int b, bool updateConditions, bool useX) { long result = useX ? (long)a + (long)b + (this.X ? 1 : 0) : (long)a + (long)b; if (updateConditions) { this.C = this.X = (result & 0x100000000) > 0; this.V = result > int.MaxValue || result < int.MinValue; this.N = result < 0; if (!useX) { this.Z = result == 0; } } return (int)result; } #endregion Add Helper Functions
The C++ version unfortunately had waaaay too many versions of ADD and I believe was overkill and complex for no reason IMO. I think the main difference was the Program Counter (PC) and thats about it but I will need to examine the code more closely. So this will be the primary focus before we translate it to VB.





Mark Thread Resolved
Reply With Quote