ReadMB -- read a .MB file This package provides a convenient, although not particularly efficient, facility for reading an arbitrary binary microcode file and parsing it. The package will read .MB files produced by Mu, Micro, or MicroD, and .DIB files produced by Micro; it will not read Dump files produced by Midas, since they are not in the documented .MB format even though they usually have the extension .MB. ReadMB(stream, maxMemx, memProc, symProc, fixProc, xfixProc) This is the only procedure defined by the package. Stream is a word- item stream from which the microcode will be read. MaxMemx is the maximum valid memory number: a reasonable value is 20. The remaining procedures are called as the file is being read, as blocks of the various types are encountered. ReadMB returns 0 when it reads the end block on the file, or a string describing the problem if the file is not in proper format or some other problem occurs. memProc(memx, width, name) is called when ReadMB encounters a memory definition. Memx is the memory number, width is the memory width in bits, and name is the memory name as a Bcpl string. MemProc should return a procedure dataProc(addr, data, memx) which will be called whenever a data word is read for the memory. Memx is passed to dataProc so that the same dataProc can be used for more than one memory if desired. symProc(memx, value, name) is called when ReadMB encounters a symbol definition. Memx is the memory number, value the value of the symbol, and name the symbol name as a Bcpl string. If symProc is omitted, it defaults to a no-op. Note that even in .MB files produced by MicroD, the values of symbols in IM are imaginary, not real, addresses. fixProc(memx, addr, field, value) is called when ReadMB encounters a fixup. Memx is the memory number, addr the address within the memory, firstBit the first bit of the field within the word, lastBit the last bit of the field, and value the value to be stored into the field. If fixProc is omitted, ReadMB will return with an error string if a fixup is encountered. xfixProc(memx, addr, firstBit, lastBit, name) is called when ReadMB encounters a fixup that references an external symbol. The parameters are the same as for fixProc, except that name is the symbol name, a Bcpl string. If xfixProc is omitted, ReadMB will return with an error string if an external fixup is encountered. MBDataSeqNo Every data item in a .MB file contains a field which Micro uses for the line number in the source file, and the other processors do not use. Since this field is of no known use, ReadMB leaves it in the static MBDataSeqNo when calling a dataProc rather than passing it as a parameter. ------------ Copyright Xerox Corporation 1980