DIRECTORY BitOps, IO, TerminalIO; Integrate: CEDAR PROGRAM IMPORTS BitOps, IO, TerminalIO = BEGIN BoolInt: PROC [bool: BOOL] RETURNS [int: INT] = { RETURN[IF bool THEN 1 ELSE 0]; }; y: ARRAY[0..11] OF BOOL _ ALL[FALSE]; x: ARRAY[0..2] OF BOOL _ ALL[FALSE]; carry, extend: BOOL; printy: BitOps.BitDWord _ BitOps.BitDWordZero; y[10] _ y[9] _ TRUE; FOR cycle: INT IN [0..50] DO FOR count: INT IN [0..11] DO a, b, ci, s, co: BOOL; a _ SELECT count FROM 0,1,2 => x[count], 3 => FALSE, 4,5,6,7,8,9,10,11 => y[0], ENDCASE => ERROR; b _ SELECT count FROM 0,1,2,3 => NOT y[8], 4,5,6,7 => y[8], 8,9,10,11 => extend, ENDCASE => ERROR; ci _ SELECT count FROM 0 => TRUE, 4 => FALSE, ENDCASE => carry; s _ ((a#b)#ci); co _ (a AND b) OR (a AND ci) OR (b AND ci); FOR bit: INT IN [0..10] DO y[bit] _ y[bit+1]; ENDLOOP; IF count=3 THEN extend _ s; carry _ co; y[11] _ s; ENDLOOP; FOR bit: INT IN [4..11] DO printy _ BitOps.IBID[y[bit],printy,11-bit,8] ENDLOOP; TerminalIO.PutF["\nCycle: %g, y: %g", IO.int[cycle], IO.int[printy]]; ENDLOOP; END. ΈIntegrate.mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Barth, February 23, 1990 9:23:09 am PST TerminalIO.PutF["\n %g %g %g : %g %g", IO.int[BoolInt[a]], IO.int[BoolInt[b]], IO.int[BoolInt[ci]], IO.int[BoolInt[s]], IO.int[BoolInt[co]]]; TerminalIO.PutF[" : %g %g ", IO.int[BoolInt[carry]], IO.int[BoolInt[extend]]]; FOR bit: INT DECREASING IN [0..11] DO TerminalIO.PutF["%g", IO.int[BoolInt[y[bit]]]]; ENDLOOP; Κͺ– "cedar" style˜codešœ™K™