-- file: OpNames.mesa, edited by Bruce, 20-Jun-81 16:55:14 DIRECTORY Environment USING [Byte], MopcodeNames USING [], OpTableDefs USING [], Runtime USING [GetTableBase, GlobalFrame], Strings USING [AppendSubString, EquivalentSubStrings, SubString, SubStringDescriptor]; OpNames: PROGRAM IMPORTS MopcodeNames, Runtime, Strings EXPORTS OpTableDefs = BEGIN CompStringDesc: TYPE = RECORD [offset, length: CARDINAL]; Names: LONG POINTER TO RECORD [ base: CARDINAL, mnemonic: ARRAY Environment.Byte OF CompStringDesc]; s: STRING ← [16]; ss: Strings.SubStringDescriptor; InstName: PUBLIC PROCEDURE [op: Environment.Byte] RETURNS [STRING] = BEGIN [ss.offset, ss.length] ← Names.mnemonic[op]; s.length ← 0; Strings.AppendSubString[s, @ss]; RETURN[s] END; UnknownInstruction: PUBLIC SIGNAL [name: STRING] = CODE; InstCode: PUBLIC PROCEDURE [name: STRING] RETURNS [i: Environment.Byte] = BEGIN s: Strings.SubString ← @ss; ssname: Strings.SubStringDescriptor ← [name, 0, name.length]; sname: Strings.SubString ← @ssname; FOR i IN Environment.Byte DO [s.offset, s.length] ← Names.mnemonic[i]; IF Strings.EquivalentSubStrings[s, sname] THEN EXIT; REPEAT FINISHED => BEGIN i ← 0; SIGNAL UnknownInstruction[name] END; ENDLOOP; RETURN; END; Init: PROC = { Names ← Runtime.GetTableBase[Runtime.GlobalFrame[MopcodeNames]]; ss.base ← Names.base + LOOPHOLE[Names, LONG STRING]}; Init[]; END.