Simple Scalar

Simple Scalar - for (i = 0; i < ALPHABET; i++) {...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
} void BuildMask(char * pchPhrase) { int i; int ch; unsigned iq; /* which Quad? */ int cbtUsed; /* bits used in the current Quad */ int cbtNeed; /* bits needed for current letter */ Quad qNeed; /* used to build the mask */ bzero(alPhrase, sizeof(Letter)*ALPHABET); bzero(aqMainMask, sizeof(Quad)*MAX_QUADS); bzero(aqMainSign, sizeof(Quad)*MAX_QUADS); /* Zero(alPhrase); Zero(aqMainMask); Zero(aqMainSign); */ /* Tabulate letter frequencies in the phrase */ cchPhraseLength = 0; while ((ch = *pchPhrase++) != '\0') { if (isalpha(ch)) { ch = tolower(ch); lPhrase(ch).uFrequency++; cchPhraseLength++; } } /* Build masks */ iq = 0; /* which quad being used */ cbtUsed = 0; /* bits used so far */
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: for (i = 0; i < ALPHABET; i++) { if (alPhrase[i].uFrequency == 0) { auGlobalFrequency[i] = ~0; /* to make it sort last */ } else { auGlobalFrequency[i] = 0; for (cbtNeed = 1, qNeed = 1; alPhrase[i].uFrequency >= qNeed; cbtNeed++, qNeed <<= 1); if (cbtUsed + cbtNeed > MASK_BITS) { if (++iq >= MAX_QUADS) Fatal("MAX_QUADS not large enough\n", 0); cbtUsed = 0; } alPhrase[i].uBits = qNeed-1; if (cbtUsed) qNeed <<= cbtUsed; aqMainSign[iq] |= qNeed; aqMainMask[iq] |= (Quad)alPhrase[i].uFrequency << cbtUsed; alPhrase[i].uShift = cbtUsed; alPhrase[i].iq = iq; cbtUsed += cbtNeed; } } } PWord NewWord(void) { PWord pw;...
View Full Document

Page1 / 2

Simple Scalar - for (i = 0; i < ALPHABET; i++) {...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online