private int POP(RegisterIndexPair rp)
        {
            /*
             * Stack:
             * E rp+1
             * D rp
             */

            registers[rp.RHS] = Pop8();
            registers[rp.LHS] = Pop8();

            if (rp == RegisterIndexPair.PSW)
            {
                /*http://www.vcfed.org/forum/archive/index.php/t-63090.html
                 * Issue #1: Always Clear Bit 5 and Bit 3, and Set Bit 1 for POP PSW
                 * instruction.
                 */
                /*Flags &= (0xff - 0x20 - 0x08);
                 * Flags |= 2;*/

                Flags &= 0b11010111;
                Flags |= 0b00000010;
            }

            return(10);
        }
        // The most significant 8 bits of data are stored at the memory address one less than the contents of the stack pointer.
        // The least significant 8 bits of data are stored at the memory address two less than the contents of the stack pointer.
        private int PUSH(RegisterIndexPair rp)
        {
            /*
             * Assume that register D contains 8F,
             *             register E contains 9D,
             * and the stack pointer contains 3A2C.
             *
             * 3A2C ?? <-- stackPointer
             *
             * Then the instruction: PUSH D
             *
             * stores the D register at memory address 3A2B, stores the E register at memory address 3A2A, and then
             * decrements the stack pointer by two, leaving the stack pointer equal to 3A2A.
             *
             * 3A2A 9D (contents of E) <-- stackPointer
             * 3A2B 8F (contents of D)
             * 3A2C ??
             */

            Push8(registers[rp.LHS]);
            Push8(registers[rp.RHS]);
            return(11);
        }
Ejemplo n.º 3
0
 // "If register B contains 3F and register C contains 16,
 // the instruction: STAX B will store the contents of the accumulator at memory location 3F16H."
 private int STAX(RegisterIndexPair rp)
 {
     mem[registers[rp]] = Accumulator;
     return(7);
 }
Ejemplo n.º 4
0
 // LDAX Load Accumulator
 //   If register D contains 93H and register E contains 8BH, the instruction: LDAX D will load the accumulator from memory location 938BH.
 private int LDAX(RegisterIndexPair rp)
 {
     Accumulator = mem[registers[rp]];
     return(7);
 }