GenFieldTest.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Russ Atkinson (RRA) March 31, 1986 9:38:28 pm PST
DIRECTORY
DragOpsCross,
DragOpsCrossUtils,
HandCoding,
HandCodingPseudos,
HandCodingSupport;
GenFieldTest: CEDAR PROGRAM
IMPORTS DragOpsCrossUtils, HandCoding, HandCodingPseudos, HandCodingSupport
= BEGIN OPEN HandCoding, HandCodingPseudos, HandCodingSupport;
CARD: TYPE = LONG CARDINAL;
Word: TYPE = DragOpsCross.Word;
ZerosWord: Word = DragOpsCross.ZerosWord;
Global labels for routines to be tested
textFetch: Label ← NIL;
textStore: Label ← NIL;
byteFetchUnchecked: Label ← NIL;
byteStoreUnchecked: Label ← NIL;
bytePtrFetch: Label ← NIL;
bytePtrStore: Label ← NIL;
extractField: Label ← NIL;
extractFieldSingle: Label ← NIL;
depositField: Label ← NIL;
depositFieldSingle: Label ← NIL;
All: PROC = {
area: Area = GetCurrentArea[];
textFetch ← GetGlobalLabel["Basics.TextFetch"];
textStore ← GetGlobalLabel["Basics.TextStore"];
byteFetchUnchecked ← GetGlobalLabel["Basics.ByteFetchUnchecked"];
byteStoreUnchecked ← GetGlobalLabel["Basics.ByteStoreUnchecked"];
bytePtrFetch ← GetGlobalLabel["Basics.BytePtrFetch"];
bytePtrStore ← GetGlobalLabel["Basics.BytePtrStore"];
TestBytes[];
extractField ← GetGlobalLabel["Basics.ExtractField"];
extractFieldSingle ← GetGlobalLabel["Basics.ExtractFieldSingle"];
depositField ← GetGlobalLabel["Basics.DepositField"];
depositFieldSingle ← GetGlobalLabel["Basics.DepositFieldSingle"];
TestFields[];
MakeLabelGlobal["GenFieldTest.startTest", GenLabelHere[]];
Halt[0];
};
TestBytes: PROC = {
c0: RegSpec = reg0;
rP: RegSpec = reg1;
rBP: RegSpec = reg2;
MakeLabelGlobal["GenFieldTest.TestBytes", GenLabelHere[]];
drASL[377B]; -- init stack to initial level
drLC0[];
drLIB[8];
drDFC[UseLabel32[GetGlobalLabel["Basics.AllocVector"]]];
drLIB[6]; drPSB[0]; drLIB[6]; drPSB[1];
drWRI[c0, rP, 2]; drWRI[c0, rP, 3]; drWRI[c0, rP, 4];
drWRI[c0, rP, 5]; drWRI[c0, rP, 6]; drWRI[c0, rP, 7];
drLRn[rP];
drADDB[8];
drSHL[DragOpsCrossUtils.FieldDescriptorToCard[[mask: 32, shift: 2]]];
{
Test textFetch & textStore
drLRn[rP];
drLIB[3];
drLIB[33];
drDFC[UseLabel32[textStore]];
drLRn[rP];
drLIB[4];
drLIB[44];
drDFC[UseLabel32[textStore]];
drLRn[rP];
drLIB[3];
drDFC[UseLabel32[textFetch]];
drSUBB[33];
drRBC[topDst, popSrc, const1];
drLRn[rP];
drLIB[4];
drDFC[UseLabel32[textFetch]];
drSUBB[44];
drRBC[topDst, popSrc, const1];
};
{
Test byteFetchUnchecked & byteStoreUnchecked
drLIB[133];
drLRn[rP];
drLIB[3+8];
drDFC[UseLabel32[byteStoreUnchecked]];
drLIB[144];
drLRn[rP];
drLIB[4+8];
drDFC[UseLabel32[byteStoreUnchecked]];
drLRn[rP];
drLIB[3+8];
drDFC[UseLabel32[byteFetchUnchecked]];
drSUBB[133];
drRBC[topDst, popSrc, const1];
drLRn[rP];
drLIB[4+8];
drDFC[UseLabel32[byteFetchUnchecked]];
drSUBB[144];
drRBC[topDst, popSrc, const1];
};
{
Test bytePtrFetch & bytePtrStore
drLIB[233];
drLRn[rBP];
drADDB[3];
drDFC[UseLabel32[bytePtrStore]];
drLIB[244];
drLRn[rBP];
drADDB[4];
drDFC[UseLabel32[bytePtrStore]];
drLRn[rBP];
drADDB[3];
drDFC[UseLabel32[bytePtrFetch]];
drSUBB[233];
drRBC[topDst, popSrc, const1];
drLRn[rBP];
drADDB[4];
drDFC[UseLabel32[bytePtrFetch]];
drSUBB[244];
drRBC[topDst, popSrc, const1];
};
};
TestFields: PROC = {
c0: RegSpec = reg0;
rP: RegSpec = reg1;
MakeLabelGlobal["GenFieldTest.TestFields", GenLabelHere[]];
drASL[377B]; -- init stack to initial level
drLC0[];
drLIB[8];
drDFC[UseLabel32[GetGlobalLabel["Basics.AllocVector"]]];
drLIB[6]; drPSB[0]; drLIB[6]; drPSB[1];
drWRI[c0, rP, 2]; drWRI[c0, rP, 3]; drWRI[c0, rP, 4];
drWRI[c0, rP, 5]; drWRI[c0, rP, 6]; drWRI[c0, rP, 7];
{
Test extractFieldSingle & depositFieldSingle
singleTest: PROC [bitOffset: [0..256], bits: [0..32], value: INT, background: INT ← -1] = {
drLIQB[DragOpsCrossUtils.IntToWord[background]];
drSRIn[rP, bitOffset/32];
drLRn[rP];
drLIB[bitOffset];
drLIB[bits];
drLIQB[DragOpsCrossUtils.IntToWord[value]];
drDFC[UseLabel32[depositFieldSingle]];
drLRn[rP];
drLIB[bitOffset];
drLIB[bits];
drDFC[UseLabel32[extractFieldSingle]];
drLIQB[DragOpsCrossUtils.IntToWord[value]];
drRVSUB[belowDst, popSrc, belowSrc];
drRBC[topDst, popSrc, const1];
IF background # 0 THEN singleTest[bitOffset, bits, value, 0];
};
singleTest[3*32, 7, 123B];
singleTest[3*32+9, 7, 123B];
singleTest[4*32-7, 7, 123B];
singleTest[3*32, 32, -1];
singleTest[3*32, 1, 1];
};
{
Test extractField & depositField
doubleTest: PROC [bitOffset: [0..256], bits: [0..32], value: INT, background: INT ← -1] = {
drLIQB[DragOpsCrossUtils.IntToWord[background]];
drSRIn[rP, bitOffset/32];
drLRn[rP];
drLIB[bitOffset];
drLIB[bits];
drLIQB[DragOpsCrossUtils.IntToWord[value]];
drDFC[UseLabel32[depositField]];
drLRn[rP];
drLIB[bitOffset];
drLIB[bits];
drDFC[UseLabel32[extractField]];
drLIQB[DragOpsCrossUtils.IntToWord[value]];
drRVSUB[belowDst, popSrc, belowSrc];
drRBC[topDst, popSrc, const1];
IF background # 0 THEN doubleTest[bitOffset, bits, value, 0];
};
doubleTest[4*32-3, 7, 123B]; -- test the boundary-crossing cases
doubleTest[4*32-16, 32, -1];
doubleTest[3*32, 7, 123B];
doubleTest[3*32+9, 7, 123B];
doubleTest[4*32-7, 7, 123B];
doubleTest[3*32, 32, -1];
doubleTest[3*32, 1, 1];
};
};
END.