MDFixupJCNImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Willie-Sue, May 6, 1986 1:48:18 pm PDT
taken from mdfixup.bcpl
DIRECTORY
Basics,
IO,
Rope,
MDDefs,
MDFields,
MDGlobalVars,
MDOps,
MDUtils;
MDFixupJCNImpl: CEDAR PROGRAM
IMPORTS
Basics, MDGlobalVars, MDUtils
EXPORTS
MDOps
= BEGIN OPEN MDDefs, MDFields, MDGlobalVars;
IMA: TYPE = MACHINE DEPENDENT RECORD [
blank(0: 0..3): [0..17B] ← 0,
p0thru3(0: 4..7): [0..17B],
p4thru5(0: 8..9): [0..3],
wd(0:10..15): SELECT OVERLAID * FROM
wdLocal => [wd2thru5(0: 10..13): [0..17B], wd6thru7(0: 14..15): [0..3] ],
wdGlobal => [wdAll(0: 10..15): [0..77B] ],  -- not used
wdLong => [wdff(0: 10..11): [0..3], wd4thru5(0: 12..13): [0..3], wd6thru7(0:14..15): [0..3] ],
wdFast => [
wd2thru3 (0: 10..11): [0..3],
b1(0: 12..12): OneBit,
wd5thru6(0: 13..14): [0..3],
b2(0: 15..15): OneBit],
ENDCASE
];
FixupJCN: PUBLIC PROC RETURNS[ok: BOOL] = TRUSTED {
Fill in branch control fields of instructions; Does no error checking
FOR i: CARDINAL IN [0..nInstructions) DO
imPtr: IMRecordPtr = MDUtils.IMPtr[i];
i1, a0, a1: CARDINAL;
a1x: IMA;
IF imPtr.wx1.returns = 1 THEN LOOP;
i1 ← imPtr.wx1.W1AddrAndGroupLink;
IF i1 = WExt THEN LOOP;
a0 ← imPtr.wx0.W0Addr;
a1 ← MDUtils.IMPtr[i1].wx0.W0Addr;
a1x ← LOOPHOLE[a1];
Fill in JN, possibly JC and FF
SELECT TRUE FROM
(imPtr.wx2.iscond = 1) AND (imPtr.wx1.jbc = 1) => { -- must use short form
a1x: wdFast IMA = LOOPHOLE[a1];
dw1: jcnFast DimWord1 ← LOOPHOLE[imPtr.imw1];
dw1.jnFast2thru3 ← a1x.wd2thru3;
dw1.jnFast5thru6 ← a1x.wd5thru6;
imPtr.imw1 ← LOOPHOLE[dw1];
};
MDUtils.CardAnd[a1, globalZero] = 0 => { -- use global call
a1x: wdGlobal IMA = LOOPHOLE[a1];
dw1: jcnGlobal DimWord1 ← LOOPHOLE[imPtr.imw1];
dw2: DimWord2 ← LOOPHOLE[imPtr.imw2];
dw1.jcGlobal ← jcGlobalValue;
dw1.jnGlobal2thur5 ← a1x.p0thru3;
dw2.jcn6thru7 ← a1x.p4thru5;
imPtr.imw1 ← LOOPHOLE[dw1];
imPtr.imw2 ← LOOPHOLE[dw2];
};
(MDUtils.CardAnd[a1, PageMask] = MDUtils.CardAnd[a0, PageMask]) => { -- local
a1x: wdLocal IMA = LOOPHOLE[a1];
dw1: jcnLocal DimWord1 ← LOOPHOLE[imPtr.imw1];
dw2: DimWord2 ← LOOPHOLE[imPtr.imw2];
dw1.jcLocal ← jcLocalValue;
dw1.jnLocal2thru5 ← a1x.wd2thru5;
dw2.jcn6thru7 ← a1x.wd6thru7;
imPtr.imw1 ← LOOPHOLE[dw1];
imPtr.imw2 ← LOOPHOLE[dw2];
};
ENDCASE => { -- long branch
a1x: wdLong IMA = LOOPHOLE[a1];
dw1: jcnLong DimWord1 ← LOOPHOLE[imPtr.imw1];
dw2: DimWord2 ← LOOPHOLE[imPtr.imw2];
dw1.jcLong ← jcLongValue;
dw1.jnLong4thru5 ← a1x.wd4thru5;
dw2.jcn6thru7 ← a1x.wd6thru7;
dw1.ff ← Basics.BITSHIFT[LOOPHOLE[a1x], -4];
imPtr.imw1 ← LOOPHOLE[dw1];
imPtr.imw2 ← LOOPHOLE[dw2];
};
ENDLOOP;
RETURN[TRUE];
};
END.