DIRECTORY
AMBridge USING [TVToLC],
AMTypes USING [IndexToTV, TV],
Basics USING [Card16FromH, Card32FromF, FWORD, HWORD],
IO USING [PutF],
PrintTV USING [RegisterRefPrintProc, RegisterTVPrintProc, RefPrintProc, TVPrintProc];
EndianDebug:
CEDAR
PROGRAM
IMPORTS AMBridge, AMTypes, Basics, IO, PrintTV = {
PrintRefFWord: PrintTV.RefPrintProc = {
[ref: REF READONLY ANY, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: REF READONLY Basics.FWORD ← NARROW[ref];
IO.PutF[stream, "%G", [cardinal[Basics.Card32FromF[foo^]]] ];
};
PrintRefHWord: PrintTV.RefPrintProc = {
[ref: REF READONLY ANY, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: REF READONLY Basics.HWORD ← NARROW[ref];
IO.PutF[stream, "%G", [cardinal[Basics.Card16FromH[foo^]]] ];
};
PrintTVFWord: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: Basics.FWORD;
highTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 1];
lowTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 2];
hiHi: AMTypes.TV ← AMTypes.IndexToTV[highTV, 1];
hiLo: AMTypes.TV ← AMTypes.IndexToTV[highTV, 2];
loHi: AMTypes.TV ← AMTypes.IndexToTV[lowTV, 1];
loLo: AMTypes.TV ← AMTypes.IndexToTV[lowTV, 2];
foo.hi.hi ← AMBridge.TVToLC[hiHi];
foo.hi.lo ← AMBridge.TVToLC[hiLo];
foo.lo.hi ← AMBridge.TVToLC[loHi];
foo.lo.lo ← AMBridge.TVToLC[loLo];
IO.PutF[stream, "%G", [cardinal[Basics.Card32FromF[foo]]] ];
};
PrintTVHWord: PrintTV.TVPrintProc =
TRUSTED {
[tv: TV, data: REF ANY, stream: STREAM, depth: INT ← 4, width: INT ← 32, verbose: BOOL ← FALSE] RETURNS [useOld: BOOL ← FALSE]
foo: Basics.HWORD;
highTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 1];
lowTV: AMTypes.TV ← AMTypes.IndexToTV[tv, 2];
foo.hi ← AMBridge.TVToLC[highTV];
foo.lo ← AMBridge.TVToLC[lowTV];
IO.PutF[stream, "%G", [cardinal[Basics.Card16FromH[foo]]] ];
};
PrintTV.RegisterRefPrintProc[CODE[Basics.FWORD], PrintRefFWord];
PrintTV.RegisterRefPrintProc[CODE[Basics.HWORD], PrintRefHWord];
PrintTV.RegisterTVPrintProc[CODE[Basics.FWORD], PrintTVFWord];
PrintTV.RegisterTVPrintProc[CODE[Basics.HWORD], PrintTVHWord];