TeleDebUtils.mesa
Last modified:
Stewart, March 1, 1983 5:46 pm, cleanup
DIRECTORY
Inline,
IO,
TeleDebOps,
TeleLoad;
TeleDebUtils: PROGRAM
IMPORTS Inline, IO, TeleDebOps, TeleLoad
EXPORTS TeleDebOps =
{
BitOp: TYPE = PROC [a, b: UNSPECIFIED] RETURNS [UNSPECIFIED];
And: BitOp = INLINE { RETURN[Inline.BITAND[a,b]]; };
Shift: BitOp = INLINE { RETURN[Inline.BITSHIFT[a,b]]; };
loadWindowLow: PUBLIC TeleLoad.CoreAddress ← 0;
loadWindowHigh: PUBLIC TeleLoad.CoreAddress ← 57344; -- 0E000H
Failed: PUBLIC ERROR = CODE;
MCR: PUBLIC PROC [s: IO.STREAM] = {
IF s.CurrentPosition[! ANY => { s.PutChar['\n]; CONTINUE; }
] # 0 THEN s.PutChar['\n];
};
GetCoreBlock: PUBLIC PROC[host: TeleDebOps.TeleDebugData, addr: TeleLoad.CoreAddress, count: CARDINAL] RETURNS [cb: TeleLoad.CoreBlock] = {
ok: BOOLEAN;
tries: NAT;
cb ← NEW[TeleLoad.CoreBlockObject[count]];
cb.address ← addr;
cb.advice ← [FALSE, FALSE, 0];
[ok, tries] ← TeleLoad.Fetch[host.h, cb];
IF NOT ok THEN {
host.out.PutF[" ... %d byte read from %08x failed, (%d tries).\n", IO.card[count], IO.card[cb.address], IO.int[tries]];
cb←NIL;
ERROR TeleDebOps.Failed;
};
};
ReadWord: PUBLIC PROC [host: TeleDebOps.TeleDebugData, addr: TeleLoad.CoreAddress] RETURNS [v: CARDINAL] = {
RETURN [Read[host, addr] + (Shift[Read[host, addr+1], 8])];
};
Read: PUBLIC PROC [host: TeleDebOps.TeleDebugData, addr: TeleLoad.CoreAddress] RETURNS [v: CARDINAL] = {
temp: Inline.LongNumber;
blockAddr: TeleLoad.CoreAddress;
temp.lc ← addr;
temp.lc ← temp.lc - (temp.lc MOD locMaxByte);
blockAddr ← temp.lc;
IF host.cacheCB = NIL THEN host.cacheCB ← TeleDebOps.GetCoreBlock[host: host, addr: blockAddr, count: locMaxByte];
IF host.cacheCB.address # blockAddr THEN {
FlushWrites[host];
host.cacheCB ← TeleDebOps.GetCoreBlock[host: host, addr: blockAddr, count: locMaxByte];
};
RETURN[host.cacheCB.data[Inline.LowHalf[addr-blockAddr]]];
};
WriteWord: PUBLIC PROC [host: TeleDebOps.TeleDebugData, addr: TeleLoad.CoreAddress, value: CARDINAL] = {
Write[host, addr, And[value, 377B]];
Write[host, addr + 1, Shift[value, -8]];
};
Write: PUBLIC PROC [host: TeleDebOps.TeleDebugData, addr: TeleLoad.CoreAddress, value: CARDINAL] = {
temp: Inline.LongNumber;
blockAddr: TeleLoad.CoreAddress;
temp.lc ← addr;
temp.lc ← temp.lc - (temp.lc MOD locMaxByte);
blockAddr ← temp.lc;
[] ← Read[host, addr];
host.cacheCB.data[Inline.LowHalf[addr-blockAddr]] ← value;
host.dirty ← TRUE;
};
FlushWrites: PUBLIC PROC [host: TeleDebOps.TeleDebugData] = {
IF host.dirty THEN {
ok: BOOL;
tries: NAT;
[ok, tries] ← TeleLoad.Store[host.h, host.cacheCB];
IF ok THEN host.dirty ← FALSE
ELSE host.out.PutF[" Write to %08x failed (%d tries).\n", IO.card[host.cacheCB.address], IO.int[tries]];
};
};
ResetCache: PUBLIC PROC [host: TeleDebOps.TeleDebugData] = {
FlushWrites[host];
host.cacheCB ← NIL;
};
Swab: PUBLIC PROC [a: CARDINAL] RETURNS [b: CARDINAL] = {
b ← Inline.BITSHIFT[Inline.LowByte[a], 8] + Inline.HighByte[a];
};
}.