TestSHOp:
PROC [left, right:
LONG
CARDINAL, insert:
BOOLEAN, mask, shift:
CARDINAL] ~ {
leftw: Word ← CardToWord[left];
rightw: Word ← CardToWord[right];
result0, result1: Word;
control0, control1: CARDINAL;
SHBad: Label = GenLabel[];
[result0, control0] ← FUSim[left, right, insert, mask, shift];
drLIQB[CardToWord[LONG[control0 - mask]]];
drFSDB[mask];
drLIQB[leftw]; --into reg0
IF left # 0
THEN {
--Relatively uninteresting if both inputs are 0
drDUP[]; --Duplicate the left word for the SHR and SHL tests
drDUP[];
[result1, control1] ← FUSim[left, left, insert, mask, shift];
drSHR[control1];
drLIQB[result1];
drRJNEB[popSrc, belowSrcPop, UseLabel8B[SHBad]];
[result1, control1] ← FUSim[left, 0, insert, mask, shift];
drSHL[control1];
drLIQB[result1];
drRJNEB[popSrc, belowSrcPop, UseLabel8B[SHBad]];
};
drLIQB[rightw]; --into reg1
drRFU[const5, reg0, reg1];
drSHDL[control0];
drLIQB[result0];
drRJEBJ[topSrc, const5, 4B]; SetLabel[SHBad]; Pause[];
drRJNEB[popSrc, belowSrc, UseLabel8B[SHBad]];
drLIQB[rightw];
drLIQB[leftw];
drSHDR[control0];
drRJNEB[popSrc, belowSrcPop, UseLabel8B[SHBad]];
};
TestSH:
PROC [left, right:
LONG
CARDINAL] ~ {
FOR I:
CARDINAL
IN [0..32]
DO
TestSHOp[left, right, FALSE, 32, I]; --All values of shift for a mask of 32
TestSHOp[left, right, FALSE, I, 0]; --All values of mask for a shift of 0
ENDLOOP;
TestSHOp[left, right, FALSE, 1, 1];
TestSHOp[left, right, FALSE, 1, 2];
TestSHOp[left, right, FALSE, 1, 4];
TestSHOp[left, right, FALSE, 1, 8];
TestSHOp[left, right, FALSE, 1, 16];
TestSHOp[left, right, FALSE, 1, 32];
TestSHOp[left, right, FALSE, 2, 1];
TestSHOp[left, right, FALSE, 2, 2];
TestSHOp[left, right, FALSE, 2, 4];
TestSHOp[left, right, FALSE, 2, 8];
TestSHOp[left, right, FALSE, 2, 16];
TestSHOp[left, right, FALSE, 2, 32];
TestSHOp[left, right, FALSE, 4, 0];
TestSHOp[left, right, FALSE, 4, 1];
TestSHOp[left, right, FALSE, 4, 2];
TestSHOp[left, right, FALSE, 4, 4];
TestSHOp[left, right, FALSE, 4, 8];
TestSHOp[left, right, FALSE, 4, 16];
TestSHOp[left, right, FALSE, 4, 32];
TestSHOp[left, right, FALSE, 8, 1];
TestSHOp[left, right, FALSE, 8, 2];
TestSHOp[left, right, FALSE, 8, 4];
TestSHOp[left, right, FALSE, 8, 8];
TestSHOp[left, right, FALSE, 8, 16];
TestSHOp[left, right, FALSE, 8, 32];
TestSHOp[left, right, FALSE, 16, 1];
TestSHOp[left, right, FALSE, 16, 2];
TestSHOp[left, right, FALSE, 16, 4];
TestSHOp[left, right, FALSE, 16, 8];
TestSHOp[left, right, FALSE, 16, 16];
TestSHOp[left, right, FALSE, 16, 32];
These are the inserts.
FOR I:
CARDINAL
IN [0..32]
DO
TestSHOp[left, right, TRUE, 32, I]; --All values of shift for a mask of 32
TestSHOp[left, right, TRUE, I, 0]; --All values of mask for a shift of 0
ENDLOOP;
For shift >= mask, the output should always be the right input and no insert takes place; these seemed uninteresting and are done only when massiveTesting = TRUE. The hardware spec is that these are all illegal, but I try to test the ones with mask = shift anyway.
IF massiveTesting
THEN {
TestSHOp[left, right, TRUE, 1, 1];
TestSHOp[left, right, TRUE, 2, 2];
TestSHOp[left, right, TRUE, 4, 4];
TestSHOp[left, right, TRUE, 8, 8];
TestSHOp[left, right, TRUE, 16, 16];
};
TestSHOp[left, right, TRUE, 2, 1];
TestSHOp[left, right, TRUE, 4, 1];
TestSHOp[left, right, TRUE, 4, 2];
TestSHOp[left, right, TRUE, 8, 1];
TestSHOp[left, right, TRUE, 8, 2];
TestSHOp[left, right, TRUE, 8, 4];
};