示例#1
0
        static void ShiftFshKey()
        {
            FlashAddr = 0X2074;
            R0X41     = ReadFshData(R0XC1);

            if (R0X41 != 0)
            {
                for (;;)
                {
                    //			asm("BANKSEL _A.R0XAB");
                    //			asm("RRCF _A.R0XAB, F, B");
                    //			asm("RRCF _A.R0XAC, F, B");
                    //			asm("RRCF _A.R0XAD, F, B");
                    //			asm("RRCF _A.R0XAE, F, B ");
                    ulR0XAB >>= 1;

                    BytesOP.ClrBit(ref ulR0XAB, 7);
                    if (BytesOP.GetBit(ulR0XAB, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAB, 7);
                    }
                    ;

                    //           asm("BANKSEL _A.R0XAF");
                    //		   asm("RRCF _A.R0XAF, F, B");
                    //		   asm("RRCF _A.R0XB0, F, B");
                    //		   asm("RRCF _A.R0XB1, F, B");
                    //		   asm("RRCF _A.R0XB2, F, B");
                    ulR0XAF >>= 1;

                    BytesOP.ClrBit(ref ulR0XAF, 7);
                    if (BytesOP.GetBit(ulR0XAF, 27))
                    {
                        BytesOP.SetBit(ref ulR0XAF, 7);
                    }
                    ;

                    R0X41--;
                    if (R0X41 == 0)
                    {
                        break;
                    }
                }
            }

            R0XBB = 0XAB;
            R0XBC = 0XB3;
            R0X52 = 0X7F;
            R0X53 = 0X3F;

            BytesOP.SetBit(ref R0XCB, 6);
            GetFshKey();
        }
示例#2
0
        static void ShiftMixKey()
        {
            byte t;
            int  p0;

            R0XBD = 0XE0;

            for (;;)
            {
                FlashAddr = 0X1F74;
                p0        = R0XBB;
                t         = RAMBUF[p0];

                t = (byte)((t >> 1) | R0XBD);

                R0X52 = ReadFshData(t);

                t = RAMBUF[p0];

                if ((t & 1) == 0)
                {
                    R0X52 = (byte)(R0X52 >> 4);
                }

                R0X52 &= 0XF;
                p0     = R0XBC;

                if (!BytesOP.GetBit(R0XBD, 5))
                {
                    R0XBC++;

                    t   = RAMBUF[p0];
                    t <<= 4;

                    R0X52 |= t;
                }

                RAMBUF[p0] = R0X52;

                R0XBB++;

                t     = R0XBD;
                R0XBD = (byte)(R0XBD - 0X20);

                //if (CARRY==0) break;
                if (t < 0x20)
                {
                    break;
                }
            }
        }
示例#3
0
        static void GetFshKey()
        {
            byte t;
            int  p0, p1;

            R0XBD = R0X52;
            R0XBE = R0X53;

            for (;;)
            {
                R0X40 = R0XBE;

                R0X40 = (byte)((R0X40 >> 3) & 0X1F);

                t  = (byte)(R0XBC + R0X40);
                p0 = t;

                FlashAddr = 0x1E14;
                if (BytesOP.GetBit(R0XCB, 6))
                {
                    FlashAddr = 0X1EF4;
                }

                R0X41 = ReadFshData(R0XBD);

                if ((R0X41 & 0x80) == 0)
                {
                    R0XC0 = (byte)(R0X41 & 0X7);

                    FlashAddr = 0X1E14;
                    if (BytesOP.GetBit(R0XCB, 6))
                    {
                        FlashAddr = 0X1EF4;
                    }
                    R0X40 = ReadFshData(R0XBD);

                    R0X40 = (byte)((R0X40 >> 3) & 0x1F);                  // 去掉了高三位,即去掉了循环右移影响

                    t  = (byte)(R0XBB + R0X40);
                    p1 = t;

                    FlashAddr = 0X2084;
                    t         = ReadFshData(R0XC0);//(A.R0XC0);
                    t         = (byte)(t & (RAMBUF[p1]));

                    if (t != 0)
                    {
                        t = 0x80;
                    }
                }
                else
                {
                    t = 0x80;
                }

                RAMBUF[p0] = (byte)(((RAMBUF[p0]) >> 1) | t);

                R0XBD--;
                R0XBE--;
                if ((R0XBE & 0X80) != 0)
                {
                    break;
                }
            }
        }