TestC2CPrint.mesa
Copyright Ó 1991 by Xerox Corporation. All rights reserved.
TestC2CPrint: CEDAR PROGRAM = {
PutChar: PROC [ch: CHAR] = TRUSTED MACHINE CODE {
"XR�ugPutChar"
};
PutLine: PROC [] = {
PutChar[12C];
};
PutInt: PROC [i: INT] = {
stack: ARRAY [0..10] OF CHAR;
nChars: INT ¬ 0;
negative: BOOL ¬ FALSE;
IF i<0 THEN {i¬-i; negative¬TRUE};
DO
digit: NAT ¬ i MOD 10;
stack[nChars] ¬ VAL['0.ORD + digit];
nChars ¬ nChars + 1;
IF i < 10 THEN EXIT;
i ¬ i / 10;
ENDLOOP;
IF negative THEN {
stack[nChars] ¬ '-;
nChars ¬ nChars + 1;
};
PutChar[' ];
FOR n: NAT DECREASING IN [0 .. nChars) DO
PutChar[stack[n]];
ENDLOOP;
};
P: PROC [] = {
PutChar['*];
PutInt[59];
PutInt[-19];
PutLine[];
};
P[];
}.