YggInline.mesa
Copyright Ó 1985, 1987, 1988 by Xerox Corporation. All rights reserved.
Simple procedures used by several Yggdrasil components.
Last edited by
MBrown on January 30, 1984 11:31:04 am PST
Hauser, March 7, 1985 2:17:46 pm PST
Bob Hagmann May 3, 1988 10:13:39 am PDT
DIRECTORY
Basics,
ConstArith,
YggEnvironment,
YggInternal;
YggInline: CEDAR DEFINITIONS
IMPORTS
Basics,
ConstArith
= BEGIN
PageNumber: TYPE = YggEnvironment.PageNumber;
WordNumber: TYPE = YggEnvironment.WordNumber;
WordsForBytes: PROC [bytes: INT] RETURNS [words: INT] = CHECKED INLINE {
RETURN[ Basics.BITRSHIFT[bytes + Basics.bytesPerWord - 1, Basics.logBytesPerWord]];
};
BytesForWords: PROC [words: INT] RETURNS [bytes: INT] = CHECKED INLINE {
RETURN[ Basics.BITLSHIFT[words, Basics.logBytesPerWord]];
};
LongZero: UNSAFE PROC [where: LONG POINTER, nWords: CARDINAL] = TRUSTED INLINE {
Basics.Fill[where, nWords, 0] };
ShortWordsFromPages: PROC [pages: CARDINAL, deviceCharacteristics: YggEnvironment.DeviceCharacteristics] RETURNS [words: CARDINAL] = INLINE {
RETURN [Basics.BITSHIFT[value: pages, count: deviceCharacteristics.logWordsPerPage]] };
WordsFromPages: PROC [pages: PageNumber, deviceCharacteristics: YggEnvironment.DeviceCharacteristics] RETURNS [words: WordNumber] = TRUSTED INLINE {
RETURN[ConstArith.Mul[ConstArith.FromInt[pages], ConstArith.FromInt[deviceCharacteristics.wordsPerPage]]]};
PagesFromWords: PROC [words: WordNumber, deviceCharacteristics: YggEnvironment.DeviceCharacteristics] RETURNS [pages: PageNumber] = TRUSTED INLINE {
RETURN [ConstArith.ToInt[ConstArith.Div[words, ConstArith.FromCard[deviceCharacteristics.wordsPerPage]]]] };
DecomposeWords: PROC [words: WordNumber, deviceCharacteristics: YggEnvironment.DeviceCharacteristics]
RETURNS [page: PageNumber, wordInPage: CARDINAL] = TRUSTED INLINE {
q, r: ConstArith.Const;
[q, r] ← ConstArith.DivMod[words, ConstArith.FromCard[deviceCharacteristics.wordsPerPage]];
RETURN [ConstArith.ToInt[q], ConstArith.ToInt[r]]
};
END.