mirror of https://github.com/tongzx/nt5src
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
424 lines
21 KiB
424 lines
21 KiB
/***************************************************************************
|
|
Name : ENCODER.C
|
|
Comment : HDLC encoding routines
|
|
Functions: (see Prototypes just below)
|
|
|
|
Copyright (c) Microsoft Corp. 1991 1992 1993
|
|
|
|
Revision Log
|
|
Date Name Description
|
|
-------- ----- ---------------------------------------------------------
|
|
***************************************************************************/
|
|
|
|
|
|
#include "prep.h"
|
|
|
|
#include "encoder.h"
|
|
#include "debug.h"
|
|
|
|
|
|
#include "glbproto.h"
|
|
|
|
#define faxTlog(m) DEBUGMSG(ZONE_SWFRAME, m)
|
|
#define FILEID FILEID_ENCODER
|
|
|
|
extern BYTE CODEBASED EncLen[5][256], CODEBASED EncWidth[5][256];
|
|
extern WORD CODEBASED EncOut[5][256];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USHORT SWECMEXP HDLC_Encode(PThrdGlbl pTG, LPBYTE lpbSrc, USHORT cbSrc, LPBYTE lpbDst, LPENCODESTATE lpState)
|
|
{
|
|
// Processes all cbSrc input bytes
|
|
// Returns number of bytes written to lpbDst
|
|
|
|
USHORT cbDst;
|
|
|
|
#ifdef PORTABLE_CODE
|
|
BYTE StateLen = lpState->len;
|
|
BYTE StateCarry = lpState->carry;
|
|
BYTE StateWidth = lpState->enc_width;
|
|
USHORT SrcSize;
|
|
BYTE InByte;
|
|
LPBYTE CurrentSrc = lpbSrc;
|
|
LPBYTE CurrentDst = lpbDst;
|
|
ULONG EncodeWord; //must be ULONG because value can be up to 17 bits
|
|
|
|
|
|
#ifdef CLASS1_TEST_HOOKS
|
|
BYTE TstlpbDst[((USHORT)(((4 + 256 + 2) * 1.2) + 10))]; //Size = FRAMEBUFINITIALSIZE from framing.c
|
|
ENCODESTATE TstState;
|
|
LPENCODESTATE TstlpState = & TstState;
|
|
USHORT TstcbDst;
|
|
USHORT i;
|
|
USHORT BadFlag = FALSE;
|
|
CurrentDst = TstlpbDst;
|
|
#endif //CLASS1_TEST_HOOKS
|
|
|
|
|
|
for (SrcSize = cbSrc; SrcSize > 0; SrcSize--) {
|
|
InByte = *CurrentSrc++;
|
|
EncodeWord = (((ULONG)EncOut[StateLen][InByte]) << StateWidth) | StateCarry;
|
|
*CurrentDst++ = LOBYTE(EncodeWord);
|
|
EncodeWord >>= 8;
|
|
StateWidth += EncWidth[StateLen][InByte];
|
|
StateLen = EncLen[StateLen][InByte];
|
|
if (StateWidth < 8) {
|
|
StateCarry = LOBYTE(EncodeWord);
|
|
}
|
|
else {
|
|
*CurrentDst++ = LOBYTE(EncodeWord);
|
|
StateCarry = HIBYTE(EncodeWord);
|
|
StateWidth -= 8;
|
|
}
|
|
}
|
|
|
|
#ifdef CLASS1_TEST_HOOKS
|
|
TstlpState->carry = StateCarry;
|
|
TstlpState->enc_width = StateWidth;
|
|
TstlpState->len = StateLen;
|
|
TstcbDst = CurrentDst - TstlpbDst;
|
|
#else
|
|
lpState->carry = StateCarry;
|
|
lpState->enc_width = StateWidth;
|
|
lpState->len = StateLen;
|
|
cbDst = (USHORT)(CurrentDst - lpbDst);
|
|
#endif
|
|
#endif //PORTABLE_CODE
|
|
|
|
|
|
|
|
|
|
#ifdef CLASS1_TEST_HOOKS
|
|
for (i = 0;( i < cbDst) && !BadFlag; i++) {
|
|
if (lpbDst[i] != TstlpbDst[i]) {
|
|
BadFlag = TRUE;
|
|
}
|
|
}
|
|
|
|
if (BadFlag || (TstcbDst != cbDst) || (lpState->carry != TstlpState->carry) || (lpState->len != TstlpState->len) ||
|
|
(lpState->enc_width != TstlpState->enc_width)){
|
|
ERRORMSG(("HDLC_Encode: Assembly Encode != C Encode\n"));
|
|
DebugBreak();
|
|
}
|
|
#endif //CLASS1_TEST_HOOKS
|
|
|
|
return cbDst;
|
|
}
|
|
|
|
|
|
BYTE RotFlag[8] = { 0x7e, 0xfc, 0xf9, 0xf3, 0xe7, 0xcf, 0x9f, 0x3f };
|
|
BYTE LowBits[8] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
USHORT SWECMEXP HDLC_AddFlags(PThrdGlbl pTG, LPBYTE lpbDst, USHORT cbFlags, LPENCODESTATE lpState)
|
|
{
|
|
USHORT i;
|
|
|
|
// faxTlog((SZMOD "iAddF c=%02x w=%d l=%d\r\n", lpState->carry, lpState->enc_width, lpState->len));
|
|
BG_CHK(lpState->enc_width < 8);
|
|
|
|
*lpbDst = lpState->carry;
|
|
*lpbDst++ |= (0x7E << lpState->enc_width);
|
|
|
|
lpState->len = 0;
|
|
lpState->carry = RotFlag[lpState->enc_width];
|
|
// lpState->enc_width is unchanged
|
|
|
|
for(i=0; i<cbFlags-1; i++)
|
|
{
|
|
*lpbDst++ = lpState->carry;
|
|
}
|
|
// zap out high (8-width) bits of carry
|
|
lpState->carry &= LowBits[lpState->enc_width];
|
|
|
|
// faxTlog((SZMOD "xAddF c=%02x w=%d l=%d\r\n", lpState->carry, lpState->enc_width, lpState->len));
|
|
return cbFlags;
|
|
}
|
|
|
|
|
|
|
|
BYTE CODEBASED EncLen[5][256] = {
|
|
// Input Len = 0
|
|
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1,
|
|
0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 1, 2 }
|
|
|
|
}; // W2
|
|
|
|
WORD CODEBASED EncOut[5][256] = {
|
|
// Input Len = 0
|
|
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
|
|
0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
|
|
0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017,
|
|
0x018, 0x019, 0x01a, 0x01b, 0x01c, 0x01d, 0x01e, 0x01f,
|
|
0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027,
|
|
0x028, 0x029, 0x02a, 0x02b, 0x02c, 0x02d, 0x02e, 0x02f,
|
|
0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037,
|
|
0x038, 0x039, 0x03a, 0x03b, 0x03c, 0x03d, 0x03e, 0x05f,
|
|
0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047,
|
|
0x048, 0x049, 0x04a, 0x04b, 0x04c, 0x04d, 0x04e, 0x04f,
|
|
0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057,
|
|
0x058, 0x059, 0x05a, 0x05b, 0x05c, 0x05d, 0x05e, 0x09f,
|
|
0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x067,
|
|
0x068, 0x069, 0x06a, 0x06b, 0x06c, 0x06d, 0x06e, 0x06f,
|
|
0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x077,
|
|
0x078, 0x079, 0x07a, 0x07b, 0x07c, 0x07d, 0x0be, 0x0df,
|
|
0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x087,
|
|
0x088, 0x089, 0x08a, 0x08b, 0x08c, 0x08d, 0x08e, 0x08f,
|
|
0x090, 0x091, 0x092, 0x093, 0x094, 0x095, 0x096, 0x097,
|
|
0x098, 0x099, 0x09a, 0x09b, 0x09c, 0x09d, 0x09e, 0x11f,
|
|
0x0a0, 0x0a1, 0x0a2, 0x0a3, 0x0a4, 0x0a5, 0x0a6, 0x0a7,
|
|
0x0a8, 0x0a9, 0x0aa, 0x0ab, 0x0ac, 0x0ad, 0x0ae, 0x0af,
|
|
0x0b0, 0x0b1, 0x0b2, 0x0b3, 0x0b4, 0x0b5, 0x0b6, 0x0b7,
|
|
0x0b8, 0x0b9, 0x0ba, 0x0bb, 0x0bc, 0x0bd, 0x13e, 0x15f,
|
|
0x0c0, 0x0c1, 0x0c2, 0x0c3, 0x0c4, 0x0c5, 0x0c6, 0x0c7,
|
|
0x0c8, 0x0c9, 0x0ca, 0x0cb, 0x0cc, 0x0cd, 0x0ce, 0x0cf,
|
|
0x0d0, 0x0d1, 0x0d2, 0x0d3, 0x0d4, 0x0d5, 0x0d6, 0x0d7,
|
|
0x0d8, 0x0d9, 0x0da, 0x0db, 0x0dc, 0x0dd, 0x0de, 0x19f,
|
|
0x0e0, 0x0e1, 0x0e2, 0x0e3, 0x0e4, 0x0e5, 0x0e6, 0x0e7,
|
|
0x0e8, 0x0e9, 0x0ea, 0x0eb, 0x0ec, 0x0ed, 0x0ee, 0x0ef,
|
|
0x0f0, 0x0f1, 0x0f2, 0x0f3, 0x0f4, 0x0f5, 0x0f6, 0x0f7,
|
|
0x0f8, 0x0f9, 0x0fa, 0x0fb, 0x17c, 0x17d, 0x1be, 0x1df },
|
|
// Input Len = 1
|
|
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
|
|
0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x00f,
|
|
0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x017,
|
|
0x018, 0x019, 0x01a, 0x01b, 0x01c, 0x01d, 0x01e, 0x02f,
|
|
0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x027,
|
|
0x028, 0x029, 0x02a, 0x02b, 0x02c, 0x02d, 0x02e, 0x04f,
|
|
0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x037,
|
|
0x038, 0x039, 0x03a, 0x03b, 0x03c, 0x03d, 0x03e, 0x06f,
|
|
0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x047,
|
|
0x048, 0x049, 0x04a, 0x04b, 0x04c, 0x04d, 0x04e, 0x08f,
|
|
0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x057,
|
|
0x058, 0x059, 0x05a, 0x05b, 0x05c, 0x05d, 0x05e, 0x0af,
|
|
0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x067,
|
|
0x068, 0x069, 0x06a, 0x06b, 0x06c, 0x06d, 0x06e, 0x0cf,
|
|
0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x077,
|
|
0x078, 0x079, 0x07a, 0x07b, 0x07c, 0x07d, 0x0be, 0x0ef,
|
|
0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x087,
|
|
0x088, 0x089, 0x08a, 0x08b, 0x08c, 0x08d, 0x08e, 0x10f,
|
|
0x090, 0x091, 0x092, 0x093, 0x094, 0x095, 0x096, 0x097,
|
|
0x098, 0x099, 0x09a, 0x09b, 0x09c, 0x09d, 0x09e, 0x12f,
|
|
0x0a0, 0x0a1, 0x0a2, 0x0a3, 0x0a4, 0x0a5, 0x0a6, 0x0a7,
|
|
0x0a8, 0x0a9, 0x0aa, 0x0ab, 0x0ac, 0x0ad, 0x0ae, 0x14f,
|
|
0x0b0, 0x0b1, 0x0b2, 0x0b3, 0x0b4, 0x0b5, 0x0b6, 0x0b7,
|
|
0x0b8, 0x0b9, 0x0ba, 0x0bb, 0x0bc, 0x0bd, 0x13e, 0x16f,
|
|
0x0c0, 0x0c1, 0x0c2, 0x0c3, 0x0c4, 0x0c5, 0x0c6, 0x0c7,
|
|
0x0c8, 0x0c9, 0x0ca, 0x0cb, 0x0cc, 0x0cd, 0x0ce, 0x18f,
|
|
0x0d0, 0x0d1, 0x0d2, 0x0d3, 0x0d4, 0x0d5, 0x0d6, 0x0d7,
|
|
0x0d8, 0x0d9, 0x0da, 0x0db, 0x0dc, 0x0dd, 0x0de, 0x1af,
|
|
0x0e0, 0x0e1, 0x0e2, 0x0e3, 0x0e4, 0x0e5, 0x0e6, 0x0e7,
|
|
0x0e8, 0x0e9, 0x0ea, 0x0eb, 0x0ec, 0x0ed, 0x0ee, 0x1cf,
|
|
0x0f0, 0x0f1, 0x0f2, 0x0f3, 0x0f4, 0x0f5, 0x0f6, 0x0f7,
|
|
0x0f8, 0x0f9, 0x0fa, 0x0fb, 0x17c, 0x17d, 0x1be, 0x1ef },
|
|
// Input Len = 2
|
|
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x007,
|
|
0x008, 0x009, 0x00a, 0x00b, 0x00c, 0x00d, 0x00e, 0x017,
|
|
0x010, 0x011, 0x012, 0x013, 0x014, 0x015, 0x016, 0x027,
|
|
0x018, 0x019, 0x01a, 0x01b, 0x01c, 0x01d, 0x01e, 0x037,
|
|
0x020, 0x021, 0x022, 0x023, 0x024, 0x025, 0x026, 0x047,
|
|
0x028, 0x029, 0x02a, 0x02b, 0x02c, 0x02d, 0x02e, 0x057,
|
|
0x030, 0x031, 0x032, 0x033, 0x034, 0x035, 0x036, 0x067,
|
|
0x038, 0x039, 0x03a, 0x03b, 0x03c, 0x03d, 0x03e, 0x077,
|
|
0x040, 0x041, 0x042, 0x043, 0x044, 0x045, 0x046, 0x087,
|
|
0x048, 0x049, 0x04a, 0x04b, 0x04c, 0x04d, 0x04e, 0x097,
|
|
0x050, 0x051, 0x052, 0x053, 0x054, 0x055, 0x056, 0x0a7,
|
|
0x058, 0x059, 0x05a, 0x05b, 0x05c, 0x05d, 0x05e, 0x0b7,
|
|
0x060, 0x061, 0x062, 0x063, 0x064, 0x065, 0x066, 0x0c7,
|
|
0x068, 0x069, 0x06a, 0x06b, 0x06c, 0x06d, 0x06e, 0x0d7,
|
|
0x070, 0x071, 0x072, 0x073, 0x074, 0x075, 0x076, 0x0e7,
|
|
0x078, 0x079, 0x07a, 0x07b, 0x07c, 0x07d, 0x0be, 0x0f7,
|
|
0x080, 0x081, 0x082, 0x083, 0x084, 0x085, 0x086, 0x107,
|
|
0x088, 0x089, 0x08a, 0x08b, 0x08c, 0x08d, 0x08e, 0x117,
|
|
0x090, 0x091, 0x092, 0x093, 0x094, 0x095, 0x096, 0x127,
|
|
0x098, 0x099, 0x09a, 0x09b, 0x09c, 0x09d, 0x09e, 0x137,
|
|
0x0a0, 0x0a1, 0x0a2, 0x0a3, 0x0a4, 0x0a5, 0x0a6, 0x147,
|
|
0x0a8, 0x0a9, 0x0aa, 0x0ab, 0x0ac, 0x0ad, 0x0ae, 0x157,
|
|
0x0b0, 0x0b1, 0x0b2, 0x0b3, 0x0b4, 0x0b5, 0x0b6, 0x167,
|
|
0x0b8, 0x0b9, 0x0ba, 0x0bb, 0x0bc, 0x0bd, 0x13e, 0x177,
|
|
0x0c0, 0x0c1, 0x0c2, 0x0c3, 0x0c4, 0x0c5, 0x0c6, 0x187,
|
|
0x0c8, 0x0c9, 0x0ca, 0x0cb, 0x0cc, 0x0cd, 0x0ce, 0x197,
|
|
0x0d0, 0x0d1, 0x0d2, 0x0d3, 0x0d4, 0x0d5, 0x0d6, 0x1a7,
|
|
0x0d8, 0x0d9, 0x0da, 0x0db, 0x0dc, 0x0dd, 0x0de, 0x1b7,
|
|
0x0e0, 0x0e1, 0x0e2, 0x0e3, 0x0e4, 0x0e5, 0x0e6, 0x1c7,
|
|
0x0e8, 0x0e9, 0x0ea, 0x0eb, 0x0ec, 0x0ed, 0x0ee, 0x1d7,
|
|
0x0f0, 0x0f1, 0x0f2, 0x0f3, 0x0f4, 0x0f5, 0x0f6, 0x1e7,
|
|
0x0f8, 0x0f9, 0x0fa, 0x0fb, 0x17c, 0x17d, 0x1be, 0x1f7 },
|
|
// Input Len = 3
|
|
{0x000, 0x001, 0x002, 0x003, 0x004, 0x005, 0x006, 0x00b,
|
|
0x008, 0x009, 0x00a, 0x013, 0x00c, 0x00d, 0x00e, 0x01b,
|
|
0x010, 0x011, 0x012, 0x023, 0x014, 0x015, 0x016, 0x02b,
|
|
0x018, 0x019, 0x01a, 0x033, 0x01c, 0x01d, 0x01e, 0x03b,
|
|
0x020, 0x021, 0x022, 0x043, 0x024, 0x025, 0x026, 0x04b,
|
|
0x028, 0x029, 0x02a, 0x053, 0x02c, 0x02d, 0x02e, 0x05b,
|
|
0x030, 0x031, 0x032, 0x063, 0x034, 0x035, 0x036, 0x06b,
|
|
0x038, 0x039, 0x03a, 0x073, 0x03c, 0x03d, 0x03e, 0x07b,
|
|
0x040, 0x041, 0x042, 0x083, 0x044, 0x045, 0x046, 0x08b,
|
|
0x048, 0x049, 0x04a, 0x093, 0x04c, 0x04d, 0x04e, 0x09b,
|
|
0x050, 0x051, 0x052, 0x0a3, 0x054, 0x055, 0x056, 0x0ab,
|
|
0x058, 0x059, 0x05a, 0x0b3, 0x05c, 0x05d, 0x05e, 0x0bb,
|
|
0x060, 0x061, 0x062, 0x0c3, 0x064, 0x065, 0x066, 0x0cb,
|
|
0x068, 0x069, 0x06a, 0x0d3, 0x06c, 0x06d, 0x06e, 0x0db,
|
|
0x070, 0x071, 0x072, 0x0e3, 0x074, 0x075, 0x076, 0x0eb,
|
|
0x078, 0x079, 0x07a, 0x0f3, 0x07c, 0x07d, 0x0be, 0x0fb,
|
|
0x080, 0x081, 0x082, 0x103, 0x084, 0x085, 0x086, 0x10b,
|
|
0x088, 0x089, 0x08a, 0x113, 0x08c, 0x08d, 0x08e, 0x11b,
|
|
0x090, 0x091, 0x092, 0x123, 0x094, 0x095, 0x096, 0x12b,
|
|
0x098, 0x099, 0x09a, 0x133, 0x09c, 0x09d, 0x09e, 0x13b,
|
|
0x0a0, 0x0a1, 0x0a2, 0x143, 0x0a4, 0x0a5, 0x0a6, 0x14b,
|
|
0x0a8, 0x0a9, 0x0aa, 0x153, 0x0ac, 0x0ad, 0x0ae, 0x15b,
|
|
0x0b0, 0x0b1, 0x0b2, 0x163, 0x0b4, 0x0b5, 0x0b6, 0x16b,
|
|
0x0b8, 0x0b9, 0x0ba, 0x173, 0x0bc, 0x0bd, 0x13e, 0x17b,
|
|
0x0c0, 0x0c1, 0x0c2, 0x183, 0x0c4, 0x0c5, 0x0c6, 0x18b,
|
|
0x0c8, 0x0c9, 0x0ca, 0x193, 0x0cc, 0x0cd, 0x0ce, 0x19b,
|
|
0x0d0, 0x0d1, 0x0d2, 0x1a3, 0x0d4, 0x0d5, 0x0d6, 0x1ab,
|
|
0x0d8, 0x0d9, 0x0da, 0x1b3, 0x0dc, 0x0dd, 0x0de, 0x1bb,
|
|
0x0e0, 0x0e1, 0x0e2, 0x1c3, 0x0e4, 0x0e5, 0x0e6, 0x1cb,
|
|
0x0e8, 0x0e9, 0x0ea, 0x1d3, 0x0ec, 0x0ed, 0x0ee, 0x1db,
|
|
0x0f0, 0x0f1, 0x0f2, 0x1e3, 0x0f4, 0x0f5, 0x0f6, 0x1eb,
|
|
0x0f8, 0x0f9, 0x0fa, 0x1f3, 0x17c, 0x17d, 0x1be, 0x2fb },
|
|
// Input Len = 4
|
|
{0x000, 0x001, 0x002, 0x005, 0x004, 0x009, 0x006, 0x00d,
|
|
0x008, 0x011, 0x00a, 0x015, 0x00c, 0x019, 0x00e, 0x01d,
|
|
0x010, 0x021, 0x012, 0x025, 0x014, 0x029, 0x016, 0x02d,
|
|
0x018, 0x031, 0x01a, 0x035, 0x01c, 0x039, 0x01e, 0x03d,
|
|
0x020, 0x041, 0x022, 0x045, 0x024, 0x049, 0x026, 0x04d,
|
|
0x028, 0x051, 0x02a, 0x055, 0x02c, 0x059, 0x02e, 0x05d,
|
|
0x030, 0x061, 0x032, 0x065, 0x034, 0x069, 0x036, 0x06d,
|
|
0x038, 0x071, 0x03a, 0x075, 0x03c, 0x079, 0x03e, 0x07d,
|
|
0x040, 0x081, 0x042, 0x085, 0x044, 0x089, 0x046, 0x08d,
|
|
0x048, 0x091, 0x04a, 0x095, 0x04c, 0x099, 0x04e, 0x09d,
|
|
0x050, 0x0a1, 0x052, 0x0a5, 0x054, 0x0a9, 0x056, 0x0ad,
|
|
0x058, 0x0b1, 0x05a, 0x0b5, 0x05c, 0x0b9, 0x05e, 0x0bd,
|
|
0x060, 0x0c1, 0x062, 0x0c5, 0x064, 0x0c9, 0x066, 0x0cd,
|
|
0x068, 0x0d1, 0x06a, 0x0d5, 0x06c, 0x0d9, 0x06e, 0x0dd,
|
|
0x070, 0x0e1, 0x072, 0x0e5, 0x074, 0x0e9, 0x076, 0x0ed,
|
|
0x078, 0x0f1, 0x07a, 0x0f5, 0x07c, 0x0f9, 0x0be, 0x17d,
|
|
0x080, 0x101, 0x082, 0x105, 0x084, 0x109, 0x086, 0x10d,
|
|
0x088, 0x111, 0x08a, 0x115, 0x08c, 0x119, 0x08e, 0x11d,
|
|
0x090, 0x121, 0x092, 0x125, 0x094, 0x129, 0x096, 0x12d,
|
|
0x098, 0x131, 0x09a, 0x135, 0x09c, 0x139, 0x09e, 0x13d,
|
|
0x0a0, 0x141, 0x0a2, 0x145, 0x0a4, 0x149, 0x0a6, 0x14d,
|
|
0x0a8, 0x151, 0x0aa, 0x155, 0x0ac, 0x159, 0x0ae, 0x15d,
|
|
0x0b0, 0x161, 0x0b2, 0x165, 0x0b4, 0x169, 0x0b6, 0x16d,
|
|
0x0b8, 0x171, 0x0ba, 0x175, 0x0bc, 0x179, 0x13e, 0x27d,
|
|
0x0c0, 0x181, 0x0c2, 0x185, 0x0c4, 0x189, 0x0c6, 0x18d,
|
|
0x0c8, 0x191, 0x0ca, 0x195, 0x0cc, 0x199, 0x0ce, 0x19d,
|
|
0x0d0, 0x1a1, 0x0d2, 0x1a5, 0x0d4, 0x1a9, 0x0d6, 0x1ad,
|
|
0x0d8, 0x1b1, 0x0da, 0x1b5, 0x0dc, 0x1b9, 0x0de, 0x1bd,
|
|
0x0e0, 0x1c1, 0x0e2, 0x1c5, 0x0e4, 0x1c9, 0x0e6, 0x1cd,
|
|
0x0e8, 0x1d1, 0x0ea, 0x1d5, 0x0ec, 0x1d9, 0x0ee, 0x1dd,
|
|
0x0f0, 0x1e1, 0x0f2, 0x1e5, 0x0f4, 0x1e9, 0x0f6, 0x1ed,
|
|
0x0f8, 0x1f1, 0x0fa, 0x1f5, 0x17c, 0x2f9, 0x1be, 0x37d }
|
|
|
|
}; // Out
|
|
|
|
|
|
|
|
|