DIRECTORY Commander USING [CommandProc, Register], IO USING [int, PutF, rope], OneCasabaParser USING [GetReportStream], RedBlackTree USING [EachNode, EnumerateIncreasing, Table], Rope USING [ROPE], ThreeC4Support USING [GetReportStream], RiscAssembler USING [EncodingSequence, LabelInstance], RiscAssemblerATDef USING [ProgramNode], RiscAssemblerParserDef USING [ParseOneStream]; RiscAssemblerDriver: CEDAR MONITOR IMPORTS Commander, IO, OneCasabaParser, RedBlackTree, ThreeC4Support, RiscAssemblerParserDef ~ { ROPE: TYPE ~ Rope.ROPE; debugFlags: CARDINAL _ 0; magicHook: RedBlackTree.Table _ NIL; RiscAssemblerProc: Commander.CommandProc ~ { ENABLE { ThreeC4Support.GetReportStream => RESUME[cmd.out]; OneCasabaParser.GetReportStream => { result _ $Failure; RESUME[cmd.out] }; }; root: RiscAssemblerATDef.ProgramNode; result _ $Success; -- bad assumption? root _ NARROW[RiscAssemblerParserDef.ParseOneStream[cmd.in, debugFlags, cmd.out]]; IF ( result = $Failure ) THEN { IO.PutF[cmd.out, "Syntax Errors Detected.\n"]; } ELSE { PrintEntry: RedBlackTree.EachNode ~ { entry: RiscAssembler.LabelInstance ~ NARROW[data]; IO.PutF[cmd.out, "\t%g: %g (%g)\n", IO.rope[entry.text], IO.int[entry.address], IO.int[entry.definedAt] ]; }; code: RiscAssembler.EncodingSequence; symbols: RedBlackTree.Table; next: INT; IO.PutF[cmd.out, "No Syntax Errors Detected.\n"]; [code, symbols, next] _ root.procs.Assemble[root]; IO.PutF[cmd.out, "Number of Instructions: %g.\n", IO.int[(next - 1)]]; magicHook _ symbols; RedBlackTree.EnumerateIncreasing[symbols, PrintEntry]; }; }; riscassemblerdoc: ROPE ~ " < file\n\tWhere the contents of file is assembly code for a 'Risc' machine"; Commander.Register["RiscAssembler", RiscAssemblerProc, riscassemblerdoc]; }... ŒRiscAssemblerDriver.Mesa Copyright Σ 1987 by Xerox Corporation. All rights reserved. Bill Jackson (bj) May 27, 1987 8:04:10 pm PDT Κ ˜™Icode™