--m.stone: November 12, 1980 2:26 PM
DIRECTORY
MicrocodeDefs: FROM "MicrocodeDefs",
D0FloatDefs: FROM "D0FloatDefs",
MiscDefs: FROM "MiscDefs" USING [DestroyFakeModule],
Mopcodes: FROM "Mopcodes" USING [zMISC],
SegmentDefs: FROM "SegmentDefs";

MicrocodeLoader: PROGRAM IMPORTS MicrocodeDefs, MiscDefs, SegmentDefs EXPORTS MicrocodeDefs, D0FloatDefs =
BEGIN


InitMicrocode: PUBLIC PROCEDURE =
BEGIN
IF SegmentDefs.GetMemoryConfig[].AltoType = D0 THEN
LoadRam[MicrocodeDefs.MicrocodeImage,TRUE];
END;

LoadRamAndJump
: PROCEDURE [LONG POINTER, BOOLEAN] =
MACHINE CODE BEGIN
Mopcodes.zMISC,3;
END;

LoadRam: PUBLIC PROCEDURE [microcode: PROGRAM,andJump: BOOLEAN ← FALSE] =
BEGIN
uImageFile: SegmentDefs.FileSegmentHandle;
uCode: LONG POINTER;
offset: CARDINAL;
debug: BOOLEAN ← TRUE;

[uImageFile,offset] ← MiscDefs.DestroyFakeModule[LOOPHOLE[microcode]];
SegmentDefs.SwapIn[uImageFile];
uCode ← SegmentDefs.FileSegmentAddress[uImageFile]+offset;
debug ← FALSE;
LoadRamAndJump[uCode,andJump];
SegmentDefs.Unlock[uImageFile];
SegmentDefs.SwapOut[uImageFile];
END;
--execute microcode load when this module is STARTed
InitMicrocode[];

END.