示例#1
0
    //#If IncludeCreate = 1 Or IncludeValidate = 1 Then
    private void SwapBit(ref TBits BitList, ref object KeySegs)
    {
        //===============================================================================
        //   SwapBit - Swaps any two bits. The bits can differ as long as they are in
        //   the range of 0 and 15.
        //===============================================================================
        {
            // Essentially, we swap Bit1 with Bit2. We use a bitwise
            // OR operator or a bitwise AND operator depending
            // upon if the subject bit is present. We don't use
            // local variables to avoid synchronizing, especially
            // since we may be doing a bit swap on the same word.
            if ((SegmentValue(KeySegs(BitList.iWord1)) & (Math.Pow(2, BitList.iBit2))) == (Math.Pow(2, BitList.iBit2)))
            {
                KeySegs(BitList.iWord1) = HexWORD(SegmentValue(KeySegs(BitList.iWord1)) | (Math.Pow(2, BitList.iBit2)), "");
            }
            else
            {
                KeySegs(BitList.iWord1) = HexWORD(SegmentValue(KeySegs(BitList.iWord1)) & !(Math.Pow(2, BitList.iBit2)), "");
            }

            if ((SegmentValue(KeySegs(BitList.iWord2)) & (Math.Pow(2, BitList.iBit1))) == (Math.Pow(2, BitList.iBit1)))
            {
                KeySegs(BitList.iWord2) = HexWORD(SegmentValue(KeySegs(BitList.iWord2)) | (Math.Pow(2, BitList.iBit1)), "");
            }
            else
            {
                KeySegs(BitList.iWord2) = HexWORD(SegmentValue(KeySegs(BitList.iWord2)) & !(Math.Pow(2, BitList.iBit1)), "");
            }
        }
    }
        /// <summary>
        /// SelectedBit: 0..7	
        /// FileAddress: 0..127
        /// </summary>
        /// <param name="SelectedBit"></param>
        /// <param name="FileAddress"></param>
        /// <returns></returns>
        public override UInt16 Bcf(TBits SelectedBit, Byte FileAddress)
        {
            UInt16 IntelFormat = 0x00;
            UInt16 OpCode = 0x00;

            if (IsFileAddressValid(FileAddress) == true)
            {
                OpCode = (UInt16)SelectedBit;
                OpCode <<= SELECTED_BIT_POSITION;
                OpCode |= FileAddress;
                OpCode |= BCF;

                IntelFormat |= (UInt16)(OpCode & 0xFF);
                IntelFormat <<= 8;
                IntelFormat |= (UInt16)(OpCode >> 8 & 0xFF);
            }
            return IntelFormat;
        }
示例#3
0
 /// <summary>
 /// SelectedBit: 0..7 FileAddress: 0..127
 /// </summary>
 /// <param name="SelectedBit"></param>
 /// <param name="FileAddress"></param>
 /// <returns></returns>
 public abstract UInt16 Btfss(TBits SelectedBit, Byte FileAddress);