Exemplo n.º 1
0
        private ushort ManageRegister(ushort instruction, string register, int bitsToShift)
        {
            switch (InstructionHelper.GetAddressingMode(instruction, bitsToShift))
            {
            case AccessMode.IMMEDIATE:
                AddValueToMemory(register);
                break;

            case AccessMode.DIRECT:
                instruction = AddRegisterToInstruction(instruction, register, bitsToShift);
                break;

            case AccessMode.INDIRECT:
                instruction = AddIndirectAccessToInstruction(instruction, register, bitsToShift);
                break;

            case AccessMode.INDEXED:
                instruction = AddIndexedAccessToInstruction(instruction, register, bitsToShift);
                break;

            default:
                throw new AccessModeException($"{register} has no known access mode");
            }

            return(instruction);
        }