MICROMACHINE-INDEPENDENTMICROASSEMBLER11 July 1980byEdward FialaPeter DeutschButler LampsonXerox Palo Alto Research Center3333 Coyote Hill Rd.Palo Alto, CA. 94304Filed on: [Maxc1]Micro.PressSources on: [Ivy]MicroMemo.DmThis manual describes a machine-independent microassembly language originally developed for the Maxc1computer and since used for the Maxc2, Dorado, and D0 computers as well as for several smaller projects.This manual is the property of Xerox Corporation and is to be used solely for evaluative purposes. No partthereof may be reproduced, stored in a retrieval system transmited, disseminated, or disclosed to others in anyform or by any means without prior written permission of Xerox.%MpHC %<q )J6%S3C %12 $^/! )"j'")%yr&y7+y[+:yJybyhy1?yB8cOcMicro: Machine-Independent MicroAssembler11 July 19802TABLE OF CONTENTS l.Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.Assembly Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 3.Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 4.Assembly Listings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 5.Cross Reference Listings . . . . . . . . . . . . . . . . . . . . . . . . . . 8 6.Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 7.Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 7.1Builtins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .117.2Defining Symbols . . . . . . . . . . . . . . . . . . . . . . . . . . .117.3Tokens . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .137.4Neutrals and Tails . . . . . . . . . . . . . . . . . . . . . . . . . . .147.5Clause Evaluation . . . . . . . . . . . . . . . . . . . . . . . . . . .167.6Treatment of Arguments . . . . . . . . . . . . . . . . . . . . . .167.7Undefined Symbols . . . . . . . . . . . . . . . . . . . . . . . . .177.7.lDestination Addresses . . . . . . . . . . . . . . . . . . . .187.7.2Octal Numbers . . . . . . . . . . . . . . . . . . . . . . . . .187.7.3Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 8.Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18 9.Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1910.Neutrals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2011.Fields, Assignments, and Preassignments . . . . . . . . . . . . . . .2012.Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2113.Memories, Addresses, and Stores . . . . . . . . . . . . . . . . . . . .2113.1.Target Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . .2313.2.Default Statement . . . . . . . . . . . . . . . . . . . . . . . . . . .2313.3.Post Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2314.Repeat and While . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2315.Select . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2416.Bit Tables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2417.Multi-Statement Conditionals . . . . . . . . . . . . . . . . . . . . . . .2518.Trace Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .26Appendix 1. Micro Error Messages . . . . . . . . . . . . . . . . . . . . . . .27Appendix 2. Limitations of the Language . . . . . . . . . . . . . . . . . .29Appendix 3: Binary Output Format . . . . . . . . . . . . . . . . . . . . . .32Table l: Builtins . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12Table 2: Top Level Evaluation . . . . . . . . . . . . . . . . . . . . . . . . .16Table 3: Conditionals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21Table 4: Micro Binary Output File Format . . . . . . . . . . . . . . . .32 ft*6u HYt ^sYu P;W K;U N;S M;Qq L;O` P;MO R;K> L; IsF; GJ; EH; DG; BIB; @~C;>=;<?;;D;9  T;6 R;4 T;2 E;0 P;. G; ,E; *rG; (=I;&, L;$ T;"  R; J; P;uN;dK;SL;X;P;V; I; 6 U3l]EMicro: Machine-Independent MicroAssembler11 July 19803l. IntroductionThis document describes MICRO, originally implemented in 1971 for NOVA in Algol to assemblemicroprograms for the Maxc1 microprocessor. It has since been reimplemented for Alto in Bcpland is now used to assemble microprograms for Maxc1, Maxc2, Dorado, and D0. Its output formatis compatible with the MIDAS loader/debugger, for which there are versions on each of these fourmachines.Micro is a rather unspecialized one-pass assembler. It does not know anything specific about thetarget machine, but instead has a general facility for defining fields and memories, a standard string-oriented macro capability, and a rather unusual parsing algorithm which allows setting fields inmemories in a natural way by defining suitable macros and neutrals with properly chosen names.This document will be of interest primarily to someone who is going to define a new assemblylanguage for some machine. There are a number of complications inside Micro that this personmust be aware of when defining the language. However, once the language has been appropriatelydefined, the interface seen by someone writing programs for a target machine is natural and simple.In other words, if you were going to write microprograms for Dorado or D0, for example, youwould need to read "The Dorado Microassembler" or "The D0 Microassembler", which definelanguages for those machines, but would probably not require this document.2. Assembly ProceduresTo assemble microprograms on your Alto, you must obtain [Maxc]Micro.run or[IVY]Micro.run. In addition, you will need to get the definition file(s) for the particularmicrolanguage that you will be using (see other relevant documentation).Micro flushes Bravo trailers, so you can use Bravo formatting in the preparation of microprograms.However, MCross, a Maxc program that produces cross-reference listings of Micro programs, doesnot ignore Bravo trailers, so you may not use any Bravo formatting features if you are going to useMCross. In addition, error messages produced during assembly have line numbers that will bemore difficult to correlate with source statements if automatic Bravo line breaks occur in the sourcetext rather than explicit carriage returns.We recommend use of GACHA8 (i.e., a relatively small fixed pitch font) for printing hardcopymicroprogram listings, and the use of GACHA10.AL for editting microprograms with Bravo. Bravotab stops should be set at precisely 8 character interals for identical tabulation in Bravo and MCross.The two relevant lines in USER.CM for Bravo are:FONT:0 GACHA 8 GACHA 10TABS: Standard tab width = 1795You will probably want to delete the other Font lines for Bravo in USER.CM.Suppose that you have prepared a language definition file LANG.MC and a number of source filesfor assembly by Micro. Then a microassembly is accomplished by the following dialog with the ft*6u HYt ^s []uA YL WG U7) T3 P(9 NV M,` KaI G O F$!< DZL BH ?*1 =SW ;K 6(s 2u@A4 0W /!H +%tu: )G (tu: &O-/ $'> "+ HF }^ ^ A0:r:n  uK @ Q r >]oMicro: Machine-Independent MicroAssembler11 July 19804Alto Executive:MICRO/L LANG SRC0 SRC1 ... SRCnThis causes the source files "LANG.MC", "SRC0.MC", ... , "SRCn.MC" to be assembled. Thebinary output and symbol table at the end of assembly are written onto "SRCn.MB" and"SRCn.ST", the error messages onto "SRCn.ER", and an assembly listing onto "SRCn.LS".In other words, Micro assembles a sequence of source files with default extension ".MC" andoutputs four files whose extensions are ".MB", ".ER", ".LS", and ".ST". The default name forthese is the name of the last source file assembled. Direct output to particular files as follows:MICRO SYS/L/B LANG SRC0 SRC1 ... SRCNThis would cause listing output to be put on "SYS.LS" and symbol table and binary output onto"SYS.ST" and "SYS.MB".A summary of the local and global flags for Micro is as follows:Global:/Lproduces an expanded listing of the output/Nsuppress binary output/Osuppress symbol table output/Uconvert text in all source files to upper caseLocal:/Rrecover from symbol table file./Lput expanded listing on named file/Bputs binary output and symbol table output on named file with extensions .MB and .ST,respectively. Default error listing to named file./Eput error listing on named file/Sput symbol table on named file/Uconvert text in named file (and any file which it INSERT's) to upper caseLocal flags override global ones.INSERT[file];statements may be put into source files so you don't have to type as many source names on thecommand line. This is exactly equivalent to the text of file.mc. INSERT's may be nested to areasonable depth. However, although INSERT saves typing it is slower than putting the file nameson the command line because Micro uses a fast file-lookup routine to get handles on every filenamed in the command line in about 1 second; each INSERT adds an additional 1 second for filename lookup.Another shortcut is to define a command file MI containing "Micro/O/U LANG" or whatever andthen type @MI@ SRC0 ... SRCN", which avoids some typing.The SETMBEXT[.ext] builtin allows the binary output file extension to be changed from .MB tosomething else. This declaration has to be assembled before defining any memories (else the outputfile will have already been opened with extension .MB). The Dorado and D0 microassemblers usethis to change the extension to .DIB, as expected by the postprocessor, MicroD. ft*6u HYt _u:[r Xxu6" VA TA QqL O5( Mtu(:Jr% G?u S Et B@ >r: *:=/ :; ::' . 6: :5x ":3 J 2p3:0 :/h :- I *u!:'Fr #u] "-8& b?tu P K  :! 8 T!; R ^ O d =[^ Micro: Machine-Independent MicroAssembler11 July 19805Micro creates a temporary file Micro.fixups and deletes it at the end of assembly. If you abortassembly with shift-swat, you may delete it yourself.Micro's binary output is generated in one pass and consists of memory definitions, store directivesto memories, forward and external reference fixup directives, and new or changed address symbolsfor each memory. The block types written on the output file are given in Appendix 3.Micro assembles declarations at a rate of about 60 statements/second and, with typicalmicrolanguages, assembles microinstructions at about 7 statements/second. On very large assembliesthis rate slows slightly as the symbol table grows larger. The assembly time for the Maxc systemmicrocode is about 7 minutes (~2000 72-bit microinstructions, ~500 36-bit words in othermemories, ~500 definitions, and ~1400 addresses).Comments are flushed very quickly by the prescan, so do not worry about a profusion of commentsslowing assembly.Presently, the Micro-Midas system has no provision for relocating independently assembled sourceprograms. However, the Micro symbol table is dumped onto a file at the end of the assembly.Later, assembly can be continued at that point onto another binary output file, thereby reducingassembly time. For example, you can build a LANG.ST file as follows:MICRO LANGThen do all further assemblies as follows:MICRO/OU LANG/R SYS/B SRC0 ... SRCNThis saves a little assembly time but still does not allow several people to independently maintainsources used in a common system.To avoid reassembling unchanged files, one would have to partition his program into separateassemblies, each of which used absolute location-counters for the various memories. This would bedifficult, probably not as good as reassembling everything. However, if this were done, Midas couldlink external references between the different modules at load time.The MicroD program, used to post-process Micro assemblies for Dorado and D0, has limitedprovisions for relocation. Programmers using the Dorado or D0 microlanguages should read therelevant documentation. ft*6u HYt _u` ]K5 Y"A XL VDU R9V Q6- O=F Mr R  K1 H6$; Fk B&t) A.u8 ?d(8 =E::Kr 6u*:3r# 0_u Y . +"0, )WS 'E %D "P@ T d t>IMicro: Machine-Independent MicroAssembler11 July 198063. Error MessagesDuring assembly, any error messages are output both to the terminal and to the error file. If anassembly listing is being printed, the error messages are also printed there.As Micro churns through the source files it prints the name of each on the error file (and terminal),and when INSERT[file] statements appear it outputs "* FILE file ..." and "* RETURN to file"messages. These will pinpoint any error message to a particular source file.Micro error messages are in one of two forms, like the following:statement218...error messagestatementTAG+39...error messageThe first example indicates an error in a statement beginning on the 218th line of the source file.This form is used for errors that precede the first label in the source file. The second form is usedafterwards, indicating an error on the 39th line after the label "TAG". Micro also prints the sourcestatement causing the error before printing the error message.Note that the line count measures carriage returns in the source, so if you are using Bravoformatting in the source files, you may have trouble distinguishing carriage returns from line breaksinserted by Bravo's hardcopy command.ER is the builtin by which a Micro program outputs fatal and non-fatal errors, warnings, and othermessages.ER[message,stopcode,value]Blanks are squeezed out of the message argument (a literal string) by the prescan so "-" "." or otherprinting characters should be used instead of blanks in the message.Stopcode equal 0 is used for progress messages; 1 for fatal errors; 2 for ordinary errors; 3 forwarnings. A nulstring in the stopcode defaults to 0. Assembly continues from the error exceptwhen a fatal error (stopcode=1) is evaluated. Ordinary errors are counted together with Microbuiltin errors; warnings are counted separately. At the end of assembly the error and warningcounts are printed on the Alto display; only when these counts are non-zero do you have to look inthe .ER file for details.ER first prints the source statement and then the message in one of the two forms given above;then, if the value argument is present, it is evaluated (e.g., it may be an IP or other arithmeticexpression) and printed in octal; then, if stopcode is 1, assembly is aborted.When the assembly is not aborted, assembly of the statement in which the error occurred willcontinue from the point of the error. This may result in more error messages if the assembler getsconfused by an undefined symbol or some other condition. The location counter gets incrementediff at least one store is done by the statement, so a statement with an error may still generate anoutput word, or it may not. ft*6u HYt ^s []uC YM V!6/ TV? RM OA:Kr:JG:G:F Bu30 @f ?N =S> 9D 8^ 6K% 2] 1:-r *ruR (D %5H #jN ! R 4*  Z @ <" E 9N W >% 29& gG  U>]Micro: Machine-Independent MicroAssembler11 July 19807A summary of Micro builtin error messages is given in Appendix 1.4. Assembly ListingsAn expanded listing is produced only when either the global or local /L option is selected. Whenthe listing file is being produced, the information output is controlled independently for eachmemory by the LIST builtin.LIST[memory,mode]controls assembly listing output for all stores to the selected memory. The value of mode is bit-encoded as follows: 1enable listing of stores in the memory as octal numbers; by default these are divided into 12-bit groups starting at the right-most bit of the value; the bit of value 20 and theLISTFIELDS builtin modify the form of the octal printout. 2list stores in the memory as field assignments; 4produce a numerically-ordered list of symbols at end of assembly;10produce an alphabetically-ordered list of symbols at end of assembly;20makes the octal printout divide stores into 16-bit groups.The actions of these bits are or'ed. LIST may be given many times during the assembly, toenable/disable listing output for code sections with difficult bugs. The value of mode at the end ofassembly determines whether or not numerically or alphabetically-ordered address lists are printed.When a statement of the form:ANAME[(TAG: mumble)];is assembled, the listing output would be as follows:302(TAG)NNNN NNNN ... NNNNfor mode 1302(TAG)NNNNNN . . . NNNNNNfor mode 21302(TAG)Fl_3, F2_34, F3_20;for mode 2302(TAG)NNNN NNNN ... NNNNfor mode 3Fl_3, F2_34, F3_20Mode equals 0 disables all listing for the specified memory.Fl, F2, and F3 in the above example represent all the fields to which explicit assignments weremade during the assembly of (mumble). Fields which have non-zero values due to the action of aDEFAULT statement for the memory are not listed, nor are preassignments listed. Also, fieldsfilled in by forward references will be erroneously listed as containing their default value.Error messages are printed on the line after the listing of the memory word or between memorywords if no field assignments were completed in the statement.LIST[,mode], where the memory name is null, AND's mode with the listing mode for all memories ft*6u HYt _uA Ys VDu4- Ty_ R:O`r LuL JG:Fr MEt;C9:Bl+:@::?dE:=: :u= 8W 6.5 3:0;r ,u5:)r\,:&\,:$\,:!Y\, u< .tutu tu JP (5 ] CN x> 1, =]LMicro: Machine-Independent MicroAssembler11 July 19808other than the target, e.g. LIST[,0] suppresses listing of all non-target memories and LIST[,3]restores.The LISTFIELDS builtin can be used to control the assembly listing more precisely. MicroassemblesLISTFIELDS[MNAME,(clauselist)];as a word for memory MNAME and then notes the positions of all the 1-bits in the result.Thereafter, in the octal listing for that memory, rather than each field being precisely 12 or 16 bitswide, 1-bits in the word given to LISTFIELDS are taken as the rightmost bits of the fields. Forexample, if the word contains 1-bits only in positions 2, 5, and 6, the octal listing will show a 3-bitfield (bits 0:2), another 3-bit field (bits 3:5), a 1-bit field (bit 6), and then the rest of the wordchopped up into groups of 12 or 16 bits.The mode argument to LIST determines whether or not the stores are printed, but LISTFIELDScontrols the format of the numerical printout whenever that is turned on by the mode =18 bit.5. Cross Reference ListingsA Tenex program called MCross will parse source files according to Micro syntax and producecross-reference listings. Several simple files must be prepared to tailor MCross for the language filebeing used. These files eliminate the garbage tokens that would otherwise clutter the cross-referncelisting.A cross-reference listing is not very useful for small microprograms but becomes increasinglyvaluable for large systems. Consequently, if you are maintaining a large system, you will probablywish to obtain an account on our Maxc timesharing system. Occasionally, you will dump thesources on your Tenex directory and run MCross over them.A typical dialog with MCross is given below. The program is more-or-less self-documenting andwill give you a list of its commands if you type "?".@MCrossOutput file:LPT:GACHA8Machine:D(selects Dorado syntax--M for Maxc, 0 for D0)Action:N(read def's, no printout)File:LANGAction:CL(read def's, produce cross ref.)File:SRC1Action:CLFile:SRC2. . .Action:P(print operation usage statistics)Action:G(print global cross reference)Action:E@ ft*6u HYt _uI ]K Y K X:Tr QquO O[ MM Lg JGL H|( E I C@ KBrC@u >s :uL 8b 6.7 51 1%8 /I .*%5 ,_9 (1- '#5:#r:"P  : "s-:H"s::@"s::8::0:"s":("s:: F >XMicro: Machine-Independent MicroAssembler11 July 198096. CommentsMicro ignores all non-printing characters and Bravo trailers. This means that you can freely usespaces, tabs, and carriage returns to format your file for readability without in any way affecting themeaning of the statements.Comments are handled as follows:"*" begins a comment terminated by carriage return."%" begins a comment terminated by the next "%". This is used for multi-line comments.";" terminates a statement. Note that if you omit the ";" terminating a statement, and for example,put a "*" to begin a comment, the same statement will be continued on the next line.Micro has a now-obsolete method of producing conditional comments which is discussed here; atone time this was used for multi-statement conditional assembly, but now conditional assemblybuiltins discussed later are used instead.The COMCHAR builtin provides conditional assembly of a large block of instructions by alteringthe interpretation of comments.COMCHAR[char]makes *char be a comment bracket similar to %. Micro will discard everything from an occurrenceof *char through the end-of-line following the next occurrence of *char. Note that this is not quitelike % because % stops discarding immediately at its matching occurrence.You can disable this feature withCOMCHAR[]which is Micro's initial state. As an example, suppose you want to assemble one of two codesequences depending upon whether some integer symbol X is zero. You could write the following:IFE[X,0,COMCHAR[#],COMCHAR[=]];*= here is some code to skip if X neq 0 (assemble if X eq 0)...*= end of X eq 0 code...*# here is some code to skip if X eq 0 (assemble if X neq 0)...*# end of X neq 0 codeCOMCHAR[]; *Disable feature ft*6u HYt ^s []u># YF! W TV P3 Mr8 J[ H6T DT BT A.* = S ;:8r 5UuB 3] 1I .M!:*r 'uS %%::"r:!<:: ::<:~::v S=QMicro: Machine-Independent MicroAssembler11 July 1980107. StatementsAfter comments and non-printing characters are stripped out, the rest of the text formsSTATEMENTS. There is no level of program structure superior to the statement (e.g., conditionalscannot span more than one statement) except for the COMCHAR kludge.Statements are terminated by ";". You can have as many statements as you want on a text line,and you can spread statements over as many text lines as you want. Statements may be indefinitelylong.However, the size of Micro's statement buffer limits statements to 500-decimal characters at any onetime. If this is exceeded at any time during assembly of a statement, an error message is output.Since horrendous macro expansions occur during instruction assembly, overflow is a possibility, andcare is required when defining complicated macros.The special characters in statements are:"[" and "]"for enclosing builtin, macro, field, memory, and address argument lists;"(" and ")"for causing nested evaluation;"_"as the final character of the token to its left;":"to put the address to its left into the symbol table with value equal to thecurrent location in the current memory;","separates clauses or arguments;";"separates statements"#"#1, #2, etc. are the formal parameters inside macro definitions;"01234567"are number components (all arithmetic in octal)All other printing characters are ordinary symbol constituents, so it is perfectly ok to have symbolscontaining "+", "-", "&", etc. which would be syntactically significant in other languages. Also,don't forget that blanks, carriage returns, line feeds, and tabs are syntactically meaningless (flushedby the prescan), so "P+Q" = "P + Q", each of which is a single symbol.Micro handles all code generation by table lookup and minimal use of conditionals. In particular, itdoes not evaluate P+Q+l but rather looks it up in the symbol table. Since P + Q + l is the samefor a human, we have chosen to suppress all blanks. Other non-printing characters are suppressedso that control characters don't appear invisibly in print names.Note that name length is limited only by the size of the statement buffer. However, avoid definingaddress symbols longer than about 13 characters because of problems you will encounter with thedebugger Midas.Statements are divided into clauses by commas. An indefinite number of clauses may appear in astatement. ft*6u Gt ^s []u".#) YC WC TVE RB P MOS KW I!B G2 D}):A .5:?A .:=v.0:;.'%/9':8.:6K.:4.@:2 ./ /DB# -z*8 +t%'u )F &sD! $tuC "M !A  U tu(0    tu<  z >SMicro: Machine-Independent MicroAssembler11 July 198011Examples of clauses are:NAME,NAME[ARGl, ARG2, ..., ARGN],FOO_FOOl_FOO2_P+Q+lP+Q+l is a "source" while FOO, FOOl, and FOO2 are"destinations" or "sinks."P _ STEMPNAME[Nl[N2[ARG]],ARG2]_FOO[X].7.1 BuiltinsAll of the predefined operations of Micro are called builtins. With the exception of the BUILTINand INSERT builtins, none of them have a priori names but instead are assigned names by theprogrammer. Names are assigned to builtin operations by declaration statements of the form:BUILTIN[BUILTIN,l];where the second argument is the intrinsic operation number and the first argument is the name bywhich it is referred to.All builtins are called using this same syntax:NAME[ARGl, ARG2, ..., ARG9];The all-inclusive list of builtins is given in Table l. Note that the only print-names assembled intoMicro are BUILTIN and INSERT; i.e., the other names in Table 1 are chosen by convention.7.2 Defining SymbolsThe builtins BUILTIN, MACRO, NEUTRAL, MEMORY, FIELD, and SET are used to definesymbols of different types, as discussed later. The name of a defined memory can then be used todefine addresses in that memory, and addresses are also defined when labels appear in statementsbeing assembled for storage in a memory. Once a symbol has been defined, it is an error toredefine it as any other type of symbol.It is legal to change the value of a symbol of type integer.Redefining a macro is legal (but Micro prints a warning message).When an address is defined by a label, any attempt to change its value is illegal, but when definedby MEMNAME[symbol,value] it is legal to change the integer part of the value (illegal to changethe memory part of the value). ft*6u Gt _u:[r:Z:Y))W)WW:Vg:U Pv MruH K'tu ID:Fr C@uH Au >/::r 7fu"%tu 5-+ 1Uv -u-" , W *N7) (R &( #G< A cT ?  =Q+Micro: Machine-Independent MicroAssembler11 July 198012Table l: BuiltinsBuiltin No.NameDiscussionlBUILTINSection 7.12MACROMacro definition (usually the short name "M" is used), section 93NEUTRALNeutral definition (usually the short name "N" is used), sections 7.3, 104MEMORYMemory definition, section 135TARGETTarget memory declaration, section 13.16DEFAULTDefault value of memory bits, section 13.27FIELDField definition, section 11l0PFField preassignments, section 11llSETInteger definition and set, section 8l2ADDSection 8l3IPInteger part of an address, section 8l4IFSEIf-string-equals conditional, section 12l5IFAIf-field-assigned conditional, section 12l6IFEIf-integers-equal conditional, section 12l7IFGIf-integer-greater conditional, section 1220IFDEFIf-symbol-defined conditional, section 122lIFMEIf-memory-part-of-address-equals-string conditional, section 1222ERPrint error message, section 323LISTControl assembly listing, section 424INSERTInsert file, section 225NOTSection 826REPEATRepeat evaluation, section 1427ORSection 830XORSection 831ANDSection 832COMCHARMulti-statement conditionals, section 633BITTABLEDefine bit table, section 1634GETBITSection 1635SETBITSection 1636FINDBITSection 1637MEMBTSection 1640LSHIFTLeft-shift integer, section 841RSHIFTRight-shift integer, section 842FVALGet value in field, section 1143SELECTSwitchon integer, section 1544SETPOSTDefine post-evaluation macro for memory, section 13.345--Deimplemented46LISTFIELDSControl assembly listing, section 447SETMBEXTSet binary output file extension, section 250SUBSection 852ASMMODEMulti-statement conditional assembly, section 1753TRACEMODEMacro expansion tracing, section 1854WHILERepeat evaluation, section 14 ft*6u Gt$_v[w "s Xr"s W"s@V!"s%$T"sS_"s'Q"s*P"sO="sM"s%L{"sK"s%I"s(HY"s)F"s)E"s*D7"s)B"s?Au"s@"s#>"s=S"s;"s:"s90"s7"s6o"s'5"s3"s 2L"s 0"s /"s .*"s,"s+i"s*"s("s5'F"s % "s#$"s+#$"s!"s0 b"s#"s 6I,|Micro: Machine-Independent MicroAssembler11 July 1980137.3 TokensThe rules for delimiting clauses into tokens have been carefully chosen to permit the user of Microto write readable programs. The parsing of statements is strictly right-to-left and the followingdefinitions are required in explanation:An L-token terminates the token to its left.An R-token terminates the token to its right.Then:(Rgroup delimiter)Lgroup delimiter[Lbuiltin argument list delimiter]builtin argument list delimiter,LRclause delimiter:LRclause delimiter which takes the preceding token as an address in the currentmemory at the current address_LRseparator which is part of the symbol to its leftAny text with an R-token to its left and an L-token to its right constitutes a token called a symbolwhose meaning is determined by looking it up in the symbol table. Text enclosed in parentheses islexically independent of anything outside, and a parenthesized string of text is lexically equivalent tothe "tail" which its evaluation produces. The following example clarifies this.In the expression:FOO5(FOOl[FOO2]FOO3[FOO4])FOO6[FOO7]the order in which expansions are recognized assuming that each FOO expansion leaves behind notext is:FOOl[FOO2]FOO3[FOO4]FOO5FOO6[FOO7] fp*6q Gp _r [q,7 YF X(:T,:R- O`:K:J:H:F$:D7:BI1@~:>1 ;[p 9Tq/3 7P 5P 2L:.s$ +qC ):&s :% :#  #k=DMicro: Machine-Independent MicroAssembler11 July 1980147.4 Neutrals and TailsThe handling of tails, a distinguishing peculiarity of Micro, works as follows. The tail is initializedto the nulstring at the start of processing a clause. When a neutral symbol is recognized using therules for delimiting tokens (previous section), it is concatenated on the left of a string called the tailthusly:temp _ concatenate (symbol, tail);if tail eq null do; tail _ temp;else do; tail _ null; treat temp as a symbol;end;Parentheses push down the current tail and start a new null one. When the text inside iscompletely processed, its tail (null or neutral) is treated as though it were a string which hadappeared without parentheses.The use of neutral tails permits complicated machines like Maxc and Dorado to be described by arelatively small number of macros and neutrals. The following example shows how this works.Maxc has about 30 bus sources and 30 bus destinations, but not all combinations of source anddestination are legal (a slow source may not feed a slow destination). An example using the bus is:MDR_XX is a macro that expands to a store into the bus source field of the microinstruction and leavesbehind the neutral symbol B. MDR_, the next token recognized, is a macro that expands into astore into the bus destination field and leaves behind the neutral symbol B_. B_B is the nexttoken recognized. Since the connection of a fast bus source to a fast bus destination is legal, B_Bhas also been entered into the symbol table as a macro equivalent to the neutral symbol B.If B_ could not have been legally connected to B, then the B_B macro would not have beendefined, and Micro would have output an error like "B_B undefined" when assembling thestatement.Thus the number of symbols which must be defined for describing bus sources and destinations isroughly l/source plus l/destination plus a small number of macros to describe legal connections of aclass of sources to a class of destinations. Each class of objects is represented by a neutral symbol.In other words, the connection concept, which neutral tails implement, decouples sources anddestinations inside the language definition file. In conjunction with the peculiar handling of "_",this permits a natural assembly language to be defined in which the programmer thinks of sourcesflowing over buses to destinations. It is impossible to create a natural language of this type with anordinary macroassembler.Here is a more complicated example: fp*6q Gp _r [qR Y>pq XE% VD:R":Q:O= :Mr:K :I:H D@ BM A  =M ;%7 8]H 6R:3Cs /qH .*[ ,_:$ *J (@ %XD #B ! QP 04 R J;! +9  R A&   # g=[Micro: Machine-Independent MicroAssembler11 July 198015STEMP_MDR_(RTEMP_P) U (X)In this example (from Maxc1), there is an interior routing of data from P (a register) to RTEMP (anaddress in the RM memory); this routing moves data from P through the ALU and into RTEMP.The ALU data is also routed onto B (a bus) where it is or'ed with data from X (a register). Thenthe bus data is written into MDR (a register) and into STEMP (an address in the SM memory). Acrude outline of the way this is assembled is as follows:P is a macro that stores the P control in the ALUF field of the microinstruction and leaves the neutral ALU;RTEMP_ is recognized as an RM destination (details later); its address is stored in the RA field leaving theneutral RB_;RB_ALU is a (connection) macro, leaving the neutral ALU behind;X is a macro that stores the code for B_X into the BS field of the microinstruction leaving the neutral B;ALUUB is a (connection) macro that stores the code for B_ALU into the F1 field and leaves the neutral B;MDR_ is a macro that stores the code for MDR_B into the BD field leaving the neutral B_;B_B is a (connection) macro leaving the neutral B;STEMP_ is recognized as an SM destination (details later); its address is stored in the SA field leaving theneutral SB_;SB_B is a (connection) macro that stores the code for loading SM into the F2 field leaving the neutral B;B is the final tail which is thrown away.This example is as complicated as any we have used in real assemblers thus far. The constructionof "(..) U (..)" to represent merging different sources on a bus is used systematically throughout theMaxc microlanguage; sources can be given in arbitary order so, in the above example, (X) U(RTEMP_P) would also assemble. All of these factors contribute to an easily readable, easilyrememberable assembly language.In the above example, the assembler also successfully concealed some complicated alternateencoding issues from the programmer. B_ALU could have been encoded in either the BS or F1fields; the assembler picked F1 since BS was needed for B_X. SB_B could have been encoded ineither BD, F1, or F2; the assembler picked F2 because BD and F1 had already been used. Theseare some of the issues that the designer of a microlanguage must consider. fp*6q Gp:_9s [qL Z Y XUa VO T9yQqs[yNXyM, yJj?yG>,yD"FyB%3%y?d2y<:2y; y8]=,y5) 2Lq5, 0S .+/ ,L +" '(2 %M $= "P? J ?>GMicro: Machine-Independent MicroAssembler11 July 1980167.5 Clause EvaluationWhen a clause is broken into top level tokens, the possible resulting symbol types and actions aregiven by the table below:Table 2: Top Level EvaluationSymbol typeActionundefinedSee section 7.7integerError message and abort clause expansionaddress[clauselist]Carry out a store of the word assembled by the clauselist at the locationand memory of the address, and then increment the integer part of theaddress symbol.address SYMReplace by sourcemacro[SYM] (section 13)address SYM_Replace by sinkmacro[SYM] (sections 7.7, 13)unbound addressError messageMNAME[SYM,integer]Create an address symbol "SYM" in memory MNAME with value "integer"FNAME[address]Store IP[address] in field FNAME (section 11)FNAME[integer]Store integer in field FNAMEFNAME[undefined]Generate forward reference for eventual field assignment at end of assemblyor by MIDAS.macro [args]Expand it (section 9)macroExpand itneutralSee sections 7.4, 10neutral [args]Error messagebuiltin [args]Call the builtin function (Table 1) with arguments handled as discussed insection 7.6Ultimately, the original clause must reduce through macro and neutral expansions to a series offield assignments, preassignments, and builtin calls with a neutral symbol in the "tail." The neutralsymbol is then thrown away and the next clause is evaluated.7.6 Treatment of ArgumentsMany symbol types may be followed by argument lists. The only difference among these is thatfields, memories, addresses, and most builtins must be followed by an exact number of arguments.Macros, on the other hand, may have surplus arguments (ignored) or deficient arguments (nulstringssupplied). Conditionals may omit arguments (nulstrings supplied).The nulstring argument is special in the following sense. If it appears where an integer result iswanted, it is equivalent to the value 0 (except for the AND builtin, where it is equivalent to177777); if it appears where a string is wanted, it is the nulstring; and, if it is looked up, it isundefined. Micro does not allow the programmer to define the nulstring as a symbol.Each builtin may choose one of three basic ways to receive its arguments: quoted, looked up in thesymbol table, or evaluated. Some languages have a step short of evaluation which might be called"macro expansion", but Micro does not make any distinction between macro expansion andcomplete evaluation of an argument. However, if a string of the formNAME[arguments]: fp*6q Gp _r [qpq< Y#Vgr:S"sK"s= :; "s::K"s:8"s:6 "s:5U "s :"s3 0q@ ..8 -< (r %Xq5( #U !H B 9* C P 'T ;pqp  qpq#$  *, UE: s >](CMicro: Machine-Independent MicroAssembler11 July 198017occurs in a clause being evaluated, NAME[arguments] is expanded until a string is left withoutbrackets or parentheses, and then this string is the one affected by the ":". However,IFDEF[NAME[arguments], ...]which looks up its first argument, will look up the entire string including the brackets. This is alimitation of Micro which may someday be repaired. It prevents symbol names from beinggenerated in some situations.The exact meaning of "look up" and "evaluate" changes with the builtin. Those builtins which"lookup" an argument generally do so for a symbol type check or to decide what action to carry outbased upon the symbol type. There is no way for macro definitions to get at symbol types. Onlybuiltins can do this. This is an unfortunate limitation of Micro.Argument evaluation is slightly different from clause evaluation. For example, evaluating theargument for the field assignment FNAME[VALUE] takes place as follows: evaluate the tokens inthe argument right-to-left expanding all macros and neutrals, looking for one of the following:l)Address: Use its integer part to complete the field assignments discussed in section 11.2)Unbound address: Generate a forward reference.3)Undefined symbol: Create an unbound address and generate a forward reference.4)Integer: Complete the assignment as discussed in section 11.If the argument is the nulstring, put the integer 0 into the field. If the argument is aneutral symbol, if any text is left when the address, integer, or undefined symbol is found,generate an error.Note that a neutral symbol results in no error for clause evaluation, but an error for a fieldassignment while an integer results in an error in a clause but no error in an assignment. Otherbuiltins which evaluate their arguments may have different requirements.For example, the integer builtin ADD (see section 8) accepts only integer arguments. Address[clauselist] evaluates the clauselist exactly as if it had occurred at the top level. In all cases, if partof the argument being evaluated is in parentheses, that part is evaluated exactly as if it had occurredat the top level.7.7 Undefined SymbolsThe print-name of a symbol is a character string by which the symbol can be referred to in thesource. However, when the lexical scan finds a string S of characters which is a symbol token(delimited by L or R-tokens), it looks for a symbol with print-name S. If no such symbol exists, anerror is indicated except in the following cases: fp*6q Gp _qE ]KW:Ys Vq"B TQ S OW M*8 LD JGB F.0 E =! C@/0y?pqQy<\pqy8pq*y5xpq5y2Gy0;5'y.q *(6 )4N 'iH # Q "-N b"E  Rr q9% F Ka 1 9=VMicro: Machine-Independent MicroAssembler11 July 1980187.7.l Destination AddressesS ends with _. In this case the _ is stripped off and the resulting string S' is looked up. If S' is anaddress in memory MEM, S is replaced by MEMSINK[S'] as discussed in section 11.7.7.2 Octal NumbersS consists entirely of octal characters with an optional leading "-" sign. In this case it is treated likea symbol of type integer whose value is the octal number. Note that integers may not be largerthan l6 bits. Micro does not allow an integer string to be entered into the symbol table, whichwould usurp the natural use of that integer.7.7.3 LiteralsS starts with an octal character or with a "-" followed by an octal character. In this case the "-" (ifany) is stripped off and the rest is split into a head OCT and a tail SYM such that OCT consistsentirely of octal characters and SYM does not start with an octal character. Then the macro SYMor -SYM is called as described below.The first argument of SYM is the four right-most octal characters. The second argument is the nextfour octal characters, and so on until the octal characters are used up. For example,3743652l000Vand-1234567Vare replaced byV[l000,3652,374]and-V[4567,123].The awkwardness of the l6-bit limitation for integers is clearly pointed out by this kludge. ClearlyV[3743652l000] would have been much easier to work with and would have been possible if theinteger size was greater than or equal to the memory size. Also, going from a three-integer 36-bitresult back to a text string is made impractical by the integer size limit.8. IntegersMicro permits use of integer variables constrained to l6 bits.SET[NAME,VALUE]looks up its first argument and evaluates its second with the following results:Type of NameType of ValueActionUndefinedIntegerEnter NAME in the symbol table with type integer and valueVALUE.IntegerIntegerChange the value of NAME to VALUE. fp*6q Gp _r [q\ YO Ur R"qX PWQ N&: L, H|r E q71 C@I Au3- ?% <8B! :nV:7s :5 2Lq:.s:-z *+qT (`= &\ $K ?u q>:~s 0qP:t P )W:sP)W))W2: DP)W" !=[Micro: Machine-Independent MicroAssembler11 July 198019All other combinations are errors.The following builtins accept integers as arguments and produce an integer as value:ADD[i0, i1, ... , i7]Sums i0 ... i7SUB[i0, i1, ... , i7]Subtracts the sum of i1 ... i7 from i0NOT[i0]1's complement of i0OR[i0, i1, ... , i7]Inclusive-or of i0 ... i7XOR[i0, i1, ... , i7]Exclusive-or of i0 ... i7AND[i0, i1, ... , i7]And of i0 ... i7LSHIFT[i0, i1]Logical left-shifts the integer i0 by i1 bitsRSHIFT[i0, i1]Logical right-shifts the integer i0 by i1 bitsIn these, omitted arguments are 0's for every operation except AND, which supplies 177777 (i.e., -1)for omitted arguments. Note that octal strings may begin with an optional "-". However, thenegative of an integer-valued symbol cannot be obtained by inserting a leading "-"; -(ISYM) willnot work, either.The value of these integer operations is the unsigned octal string representing the result. Example:ADD[3, 4, l5]S is equivalent to 24S.IP[ANAME], where ANAME must be an address, is the integer part of the address. This must bedone when an address is used in an arithmetic or set expression. (It is not reasonable toautomatically take the integer part of an address because of confusion between its use as a sourceand its use as an integer).FVAL[FNAME], where FNAME must be a field, is the integer contents of the field FNAME in theword currently being assembled. If nothing has been stored in that field yet, then the contents arewhatever value was setup by the DEFAULT statement for the current memory, or are 0, if noDEFAULT statement applies.9. MacrosA symbol can be given a macro value by the clauseM[NAME, body]where the body is an arbitrary balanced string of characters (i.e., parentheses and brackets match upand are nested). Occurrences of the text#digitin the body will be replaced by the corresponding actual parameters (counting left-to-right from l)when the macro is called. Unsupplied arguments are nulstrings, surplus arguments are ignored, and#0 will be replaced by the number of arguments supplied. fp*6q Gp _q" [T:XUs"s :V"s:UM"s:S"s  :RE"s  :P"s :O= "s&:M "s' Jjq>& H R FS E  A;* ?$ <\> :F 8Y 6 30+ 1+9 /'2 .* )u &,q1:"s q\ ):us 'q[ \b 8 J>TMicro: Machine-Independent MicroAssembler11 July 198020The lexical scan of a statement is done from right to left. Whenever a symbol S is detected, it islooked up. If S turns out to be a macro, then the macro body replaces both S and the bracketedargument list immediately to the right of S, if there is one. Thus afterM[FOO, MUMBLE#l];the text FOO[E]D; expands into MUMBLEED; note that D is not a symbol since ] is not an R-token. Note that the macro body is quoted and that Micro has no provision for getting any part ofit expanded at definition time.Due to the way in which macro bodies are stored in the Micro symbol table symbols used in themacro body should be defined before the macro is defined when feasible. Assembly will be quicker ifthis rule is followed.10. NeutralsA symbol which has been declared neutral by a clause of the formNEUTRAL[SYM]is concatenated with the tail and handled as discussed in section 7.4.11. Fields, Assignments, and PreassignmentsFIELD[FNAME, leftbit, rightbit] causes a symbol of type field to be created. Leftbit and rightbitmust evaluate to integers. Also, because of the Alto's l6-bit integer size, the field should not bewider than l6 bits or else some bits of the field could never be set. Finally, leftbit must be in therange [0, 255] and rightbit in the range [leftbit, min(leftbit+l5, 255)].Clauses of the formFNAME[integer];FNAME[address];FNAME[unbound address]; orFNAME[undefined];where FNAME is a field, are used to construct memory words. A field assignment evaluates itsargument in the manner discussed in section 7.6.Field assignments also have the property that attempting more than one assignment to a field in astatement will cause an error unless the new value = old value. (When an error occurs, the valueultimately left in a field is that of the final assignment to it.) Forward references fixup the truevalue later.The preassignmentPF[FNAME, integer]does nothing if any bits of FNAME have previously been assigned. Otherwise, it is equivalent to fp*6q Gp _q5. ]KI [I:X2s Tq(1 SG QN M9p L s ;qF 7u, 3q7+ 17- 0+; .MI *:'s:&O:$:# ?q] t0 P 8,5 mQ  1:s qQ L=\Micro: Machine-Independent MicroAssembler11 July 198021FNAME[integer] except that a later assignment will overrule the preassignment and cause no error.Forward references are illegal in preassignments.The integer value stored in any field of the memory word currently being assembled may beobtained by usingFVAL[FNAME].If the field has not yet been set, FVAL returns the default value.13. ConditionalsThere are a number of builtins which will substitute the text represented by one of their argumentsif the other arguments meet some condition. These are called conditionals, summarized in Table 2.A conditional and the argument list to its right are equivalent to the "true" string, if the specifiedcondition is met, or the "false" string, if it is not met. Note that any number of arguments may beomitted. The true and false strings may be any balanced strings of characters.Although these conditionals can be used at the top level, they are intended for use inside macrodefinitions, and the string compare conditional could be used sensibly only inside macro definitions.Table 2: ConditionalsFormConditionIFE[il, i2, (true), (false)]il = i2IFG[il, i2, (true), (false)]il > i2IFDEF[sl, (true), (false)]sl in symbol table and not unbound addressIFSE[sl, s2, (true), (false)]sl = s2IFA[field, (true), (false)]any bit of field previously assignedIFME[address, sl, (true), (false)]memory name for address = stringNote that the text in the selected arm of a conditional is concatenated with the text to the right ofthe conditional before evaulation, soIFE[2,1,FOO,GLOT]ABwill evaulate GLOTAB.13. Memories, Addresses, and StoresMEMORY[MEM, wordlength, length, sourcemacro, sinkmacro]causes creation of a memory. Micro can manage a reasonable number (l5) of these memories,subject to a 255-bit word-length limit and 64K-l length limit. Once MEM has been defined,symbols can be defined as addresses in MEM and words of MEM can be initialized. fp*6q Gp _q"? ]K1 YV X:Ts QqqB Lu Isq X GL D7*< Bl.6 @0pq =/O ;ee#T6or3Cv)W:0;s)W:.)W:-z)W(:,)W:*)W!:)W")W & qP $>%: s q u$:s7 wqZ : O >YpMicro: Machine-Independent MicroAssembler11 July 198022An address ANAME in MEM is created by an expression of the form:MEM[ANAME, integer]or by usingANAME:in a clauselist which is stored in MEM.Stores into MEM are generated either by selecting an address in MEM as the target (see section13.1) or by writingANAME[(clauselist)]which stores the word assembled by the clauselist into MEM at the location of the address ANAMEand then increments ANAME. Note that the memory store and incrementing the address are doneiff one or more field assignments or preassignments result from the clauselist.The value stored is generated as follows: It is initialized according to the value assembled by theDEFAULT statement (0 if there has been no DEFAULT statement). Next, the clauselist isevaluated. Then the post macro for the memory, declared by the SETPOST builtin, is evaluated.Finally, if ANAME is out-of-bounds, an error message will occur.The sourcemacro MSRC and sinkmacro MSINK are applied when the address ANAME appears ina clauselist. If ANAME is evaluated as a token in a clauselist without a following argument list, itis replaced by the stringMSRC[ANAME].If ANAME_ appears and is undefined, it is replaced byMSINK[ANAME].Note, however, that forward and external references can be generated only in the contextFNAME[ANAME],not when ANAME is used as a source or sink. fp*6q Gp _q@:[s Xxq :U*s Qq' NiK L:IPs Fq"= D7K BlO >-7 =/S ;e'7 9@ 6(> 4^S 2:/Ds +q5:(s %XqEpq:" s pq(\ t>IMicro: Machine-Independent MicroAssembler11 July 19802313.1. Target MemoryAt any time TARGET[ANAME] will set the target address to ANAME which means that astatement of the formX: mumble;where mumble must do at least one field assignment, is equivalent toANAME[(X: mumble)];Otherwise, the target has no effect. Note that the target memory is not preserved in the /R file andmust be given again for each assembly.13.2. Default StatementBefore assembly of a clauselist for storage into a memory MEM, the word is initialized to a valuewhich may be overruled by the various assignments in the clauselist. Normally, the initial value is0, but this may be changed by the statementDEFAULT[MEM, (clauselist)];which assembles clauselist into a value that will subsequently initialize words being assembled forMEM. Note that forward references are not permitted in the clauselist and that any of the defaultsettings may be overruled by explicit assignments in a statement being assembled.13.3. Post MacrosSETPOST[MNAME,POSTMACRO]arranges things so that the macro POSTMACRO will be called just after a word has been assembledfor the memory named MNAME but just before the word is output to the binary file. IfPOSTMACRO is null, SETPOST simply turns off this feature for the memory MNAME.14. Repeat and WhileREPEAT[il,TEXT]assembles TEXT il times. This is used primarily for initializing blocks of memory and forreplicating nearly-identical instructions in diagnostics.Since TEXT cannot include ";" stores to the target memory must be put in explicitly. In otherwords, the program cannot rely on the TARGET directive to insert "ILC[TEXT]" or whatever eachtime TEXT is repeated. Note that the statement buffer is cleared after each assembly of TEXT.WHILE[il,TEXT]evaluates the expression i1, which must evaluate to an integer; so long as the result is non-zero,TEXT will be evaluated and the while will repeat. fp*6q Gp _r [q5 Y:Vs SJ<&(;A$(9 898:6:3!(290(:.:+(*N9(:'F:$" ! ((~: qW:]s :#:U : ": MV *=\Micro: Machine-Independent MicroAssembler11 July 198026 ... statements for IM16K and IM8K both 0 ...:ENDIF;... undonditionally assembled statements ...18. Trace ModeThe TRACEMODE builtin is used to produce a trace of the assembly on the .ER file. This aims atdebugging complicated macros and at performance tuning of definition files. The format of thetrace output is not particularly pretty but is self-explanatory.TRACEMODE[n,v] turns on tracing feature n if v is unequal to 0, or turns it off if v is zero. n=0traces symbol table insertions; n=1 traces all applications of the form name[args]. fp*6q Gp:_9s.:]:\1, Xr TqR R6( Q@ Mb KSZ Is=JMicro: Machine-Independent MicroAssembler11 July 198027Appendix 1. Micro Error MessagesMicro error messages are enumerated below, in which the character @ should be replaced by theprintname of the token related to the error. Unless marked with a 1, assembly continues from theerror with no special action; errors marked with 1 terminate assembly.Program Organization ErrorsSOURCE FILE @ DOES NOT EXIST1COULD NOT OPEN FILE @ FOR 'INSERT'1STORAGE FULL1Storage required during the assembly is roughly proportional to the following computation: l/2*Sum [namelength +l] for all symbols+ 6* no. symbols+ l/2*Sum [length +l] of all macro definitions.When this number is greater than the size of the buffer (approx. ? Alto words), the STORAGE FULLmessage results.TOO MANY MEMORIES1Limit is currently l5 memories.Declaration Errors@ ALREADY DEFINEDThe new definition will replace the old and this warning message will be printed.MACRO @ REDEFINEDJust a warning (doesn't increment error count)ARG NOT A MEMORY NAMEFor DEFAULT, which requires an argument to be of type memory.UNDEFINED SYMBOL @ IN 'DEFAULT'1BAD PARAMETERS FOR 'F'A field may not be larger than l6 bits nor a memory wider than 256 bits, so rightbit > 255 or rightbit-leftbit> l6 are field definition errors.MEMORY @ ALREADY USED1ILLEGAL WIDTH OR SIZE FOR 'MEMORY'1Limits are 256 bits wide and 64K-l in sizeWRONG NO. ARGS FOR '@'Only for those builtins which must have correct number of arguments.Macros may have too many or too few.ILLEGAL BUILTIN NUMBER FOR '@'1Statement Assembly ErrorsEND OF FILE INSIDE COMMENTTerminates comment and forges aheadINPUT STATEMENT TOO LONGMaximum length is 500 characters. Text to the right of the 500th character is truncated.STATEMENT TOO LONGDuring macro expansion of the input statement, the unprocessed text is never permitted to exceed 500 fp*6q Gp ^u []q*3 YBZ sYq W1XUsWq Sr PWsP N#"N K L{:JZHY)FE/:CcE:B ?@[:>m :Kr 7s:5Q 3:2). /:.= ,_, *+:(_:'i! %5% #"#:!* k: D:$ u Sr (s:# :2Y : G. y=]Micro: Machine-Independent MicroAssembler11 July 198028characters. Text to the right is truncated.MACRO ARGUMENT STORAGE FULLTruncates characters right-to-left up to matching '[' and proceeds.SYMBOL @ NOT LEGAL AS TOKENSymbol appears without its required argument list.@ MAY NOT BE FOLLOWED BY [ ]Only macros, builtins, fields, addresses, and memories may have '[' to their right.UNPAIRED ) OR ] IN ARGUMENT LISTUNPAIRED )UNPAIRED (TOO MUCH NESTING OF ( ) AND [ ] IN CLAUSELimit is 8 levelsMISSING MACRO NAME OR TAG SYMBOLNo symbol to the left of a : or [.MACRO '@' NOT DEFINEDSymbol to the left of a "[" wasn't definedTAG @ ALREADY DEFINED'TARGET' GIVEN AFTER FIELD SET1NO TARGET FOR FIELD SET1'TARGET' NOT LEGAL INSIDE A STORE1@ UNDEFINEDNot including forward references. Plunges ahead with value 0 and type integerFIELD @ DOES NOT FIT IN MEMORY @Right bit of field > right bit of memoryVALUE @ DOES NOT FIT IN FIELD @Left bits of value truncated before storeARG IN FIELD STORE NOT INTEGER OR ADDRESSDoesn't do field assignment and plunges aheadFIELD @ ALREADY SETThe new value is stored into the field. This message will occur iff new value # old value.ARG DOES NOT YIELD INTEGER VALUEAssumes 0 and proceeds. Syntax OK but undefined symbol or address instead of integer.BAD SYNTAX WHERE VALUE REQUIREDSomething complicated where a simple value expectedFIRST ARG OF 'PF' NOT FIELDNo actionFORWARD REFERENCE NOT LEGAL IN 'PF'No actionSTORE TO @ OUT OF RANGE FOR @@ BAD FIRST ARG FOR 'SET'Must be integer or undefined symbol. However, redefinition will take place.INTEGER '@' TOO LARGEInteger MOD 2**l6 is used.ARG NOT A FIELD NAME IN 'IFSET' fp*6q Gp:_9s, ]:[C Yo:X2 U:TyS RE P M K):JG H:F" D}:C* @ >?@ <= :K!: 8 :6N 4:3 ( 0:/) -V):+- ):(`[ &,:$V ":!63 : l#:   :BL  : xr C6[Micro: Machine-Independent MicroAssembler11 July 198029Appendix 2. Limitations of the LanguageMicro lacks some features and possesses certain limitations discussed below:1. It is impossible to relocate a microprogram at load time.2. Forward and external references are permitted only on field assignments which means that theoccurrence ofMDR_STEMP, or STEMP_MDRwhere STEMP is an address in SM, cannot be assembled if STEMP is a forward or externalreference. Forward references to symbols that are not addresses are also impossible.3. Significant size limits:a.Symbol table storage is tight.b.Integers are limited to 16 bits.4. It is impossible to check the memory part of an address on forward or external references. Noris it possible for programs to get at the type of a symbol, at the parameters of a field or memory, orat the name of the target memory. The 'lookup' capability of builtins is not available through anylanguage constructs.5. Macros which expand to more than one statement are impossible.6. It is impossible to pull print names apart or to construct print names except by using neutralsubsymbols. In particular, it is impossible to construct constants larger than 16 bits parametricallysuch that, if several constants contain the same value they can be assigned the same location. Thisis true because one cannot generate the print name "l420000S" (a literal) either directly from aninteger or indirectly from the value assembled by assignments. (Note that if integers were largeenough ADD[Pl, P2, ... , P7]S would generate the literal in S.)7. There are a number of situations when part of an otherwise quoted argument wants to beexpanded and there is no way to do this. For example,IFDEF[FOO[E],(true clause),(false clause)]should lead to expansion of the macro FOO[E] before checking for a defined symbol.8. Blanks in user-defined error messages are impossible.9. The REPEAT builtin should supply a ";" after each repetition of the text, so that the ILC[...] inREPEAT[n,(ILC[...])] can be omitted.10. PF [field, value] was a bad choice because it makes parameterizing the values of a fieldimpractical. For example, suppose that the function P_Pl is accomplished by setting the PS field to50. What we would like to do is to define neutrals P_ and Pl and then define the macro P_Pl asPS[50]. If the hardware is changed so that P_Pl is accomplished by PS[20] instead of PS[50], we fp*6q Gp ^u( []qL W= Ty'9 R :O`s LqV JGU F:Cc(:@[( <^ ;*pqp q 9T X 7 4B 0(: .K - Z +ER ){.3 'pq $>1) "s6:%s* qR d9  W ($ 8% I  pqH VE t =]Micro: Machine-Independent MicroAssembler11 July 198030would prefer to change only the one macro P_Pl. However, there are also several instances ofPF[PS,50] which have to be found and changed and this is the reason why PF[field, value] was abad choice. Instead, a preset-clauselist operation would have been better because then no otherusage than P_Pl would be needed.To prevent some of the above limitations or to otherwise streamline or augment the language, thefollowing changes should be considered (the ones followed by ? or ?? or ??? are not seriousproposals).1. Make integers at least 36 bits long for MAXC, and consider variable length integers. Currently,considerable inconvenience results from "making do" with l6-bit integers. Also this would make itpossible to get the literal equivalent of a constant constructed from parameters, which would allowmerging identically-valued constants.2. Provide a builtin like the one for defining fields except that it takes an additional argumentwhich is a memory name:AFIELD[AFNAME, leftbit, rightbit, memory].AFNAME[address] works like FNAME[integer] except that its argument must expand to an addressin "memory" rather than an integer, or if its argument is undefined, a forward address reference isassumed. Forward references to FNAME[undefined] would be illegal and FNAME[address] wouldbe illegal. Unbound addresses would contain the memory type. This would permit memorychecking of addresses very conveniently (currently it is cumbersome) and would permit forwardreferences to be checked also (??).3. Multi-statement macro definitions should be added. Perhaps "{" and "}" could be usedsyntactically to enclose multi-statement stuff.4. It should be permissible for an argument list to appear to the right of a neutral symbol becauseof the following usage:P_LB RSH [1]where LBRSH is a neutral symbol, P_ is a neutral symbol, and P_LBRSH is a macro. Theargument list [1] should be preserved until P_LB RSH [1] is expanded.5. In every place where an argument string is "looked up" for a builtin, all macros and neutralsshould be expanded. In other words, "looking up" an argument should be identical to evaluatingan argument, except that occurrence of any builtin causes an error. Expansion stops when a non-neutral non-macro symbol without brackets, parentheses, _, or : is left.6. Currently address_ is handled by the assembler, but undefined_ and macro_ are not handled inany special way. Similarly, an undefined source is not handled. It might be useful to have thesecases result in the substitutions UDEST[undefined], MDEST[macro] and USRC[undefined]. Thiswould permit forward or external references to succeed where they don't currently and wouldpermit macros which expand to addresses to be used. MDEST, UDEST, and USRC should bemacro names selectable by the programmer. fp*6q Gp _qN ]K^ [ U Y VDF TyD R O=\ MrZ Kc I% Fk W D:ARs* >qQ <8` :nZ 8C 6] 5# 1G // ,_M *:'Fs #q8 "-E T =" &#= [H  pq"p qpq @" TL U K ) " =[^Micro: Machine-Independent MicroAssembler11 July 1980317. Currently the TARGET directive causes a top level statement to be equivalent toTARGLC[(#1)];where #1 stands for the top level statement. This could be changed to a general macro whose firstargument is the clauselist of the statement. However, this would slow assembly.8. Instead of causing an error, integer results should be treated at the top level as neutral symbolsequal to the octal text string for the integer. This would permit arithmetic to be performed and theresult concatenated with text to select one of many macros or address symbols. fp*6q Gp _qS:[s XxqK VP S<B$ QqS ONd MN=DMicro: Machine-Independent MicroAssembler11 July 198032Appendix 3. Binary Output FormatMicro outputs binary memory images as a series of short blocks of l6-bit words. Each block beginswith a word that specifies the type of the block; the number and format of following words dependon the block type. During its pass through the source files, Micro outputs a message to the fileMicro.fixups whenever it encounters an assignmentFNAME [NAME]and NAME is undefined. At the end of processing the source files, Micro reads back Micro.fixupsand outputs either a type 3 or type 6 message (see below) to the binary file depending uponwhether the symbol was a forward reference or undefined. Finally, it orders new or changedaddress symbols by memory and outputs them to the binary file.Midas can link up external address references at load time. Address symbols for Midas to use inlinking up external references are output as described below.Table 4: Micro Binary Output File FormatTypeFollowed byUse 0nothingIndicates the end of the binary file. 1source line # (1 word);data (N words)Specifies a data word to go in the current memory at the currentlocation. The current location is to be incremented. N is just largeenough to cover the width of the memory, and the value is left-justified, e.g., for a 36-bit memory N=3 and the first word goes inbits 0:15, the second in 16:31, and bits 0:3 of the third in 32:35.The source line # is zero if the word was generated by an INSERTfile, and has bit 0 set if the word was generated in the main file by aSTORE. 2memory # (1 word);location (1 word)Sets the current memory and the current location. Memory numbersare related to memory names by type 4 blocks (see below). 3memory # (1 word);location (1 word);first bit * 256 + last bit (1 word);value (1 word)Specifies a forward reference fixup. The value is to be stored into thegiven bits at the given location in the given memory. (Currentmemory and location settings are not affected.) 4memory # (1 word);width of memory in bits (1 word);symbolic name of memory (L words)Correlates a memory number with a user-supplied name.The name is packed 2 8-bit characters per word terminated by a null(all 0's) character; L=(C+2)/2 where C is the number of charactersin the name. The type 4 block defining a memory will appear beforeany type 2 or 3 blocks storing into that memory. 5memory # (1 word);value (1 word);address symbol name (L words)Gives the definition of an address symbol. There is a type 5 block fp*6q Gp ^u! []q11 YJ WN U1:Rs O`q%; M-. K[ J> F5+ D=ARr)y>&t "s);s"s%)87 "s+ "s5@"s4^("s2$"s1C"s.6 "s-z :"s,)){ ("s."s&9)$ "!Y$ "s;"s#"s7/) 8!!"sv5"s<"sC"sTC"s0)U   "s 3: =]LMicro: Machine-Independent MicroAssembler11 July 198033for every new or changed address symbol. All type 5 blocks appeartogether at the end of the binary file. 6memory # (1 word);location (1 word);first bit * 256 + last bit (1 word);undefined symbol name (L words)Specifies a reference to an undefined (external) symbol. The firstthree words have the same interpretation as for block type 3.The Midas program accepts any of the block types above. In addition, Midas accepts the following compact block typeswhich are more compact than the ones above and use less storage. 11block address (l word);word count N (l word);N data words;The left-half of the word containing the type is the memory #. TheN data words are in the same form as block type 1. 12address (l word);Bcpl string (L words);The left-half of the word containing the type is the memory #. Thefirst word of the Bcpl string contains a character count in the firstbyte (0:7), followed by the characters of the string. fp*6q Gp"s_9s-"s]')[: YXx$W"sU9 "sTV: QNd O@)LKJ# "s@"sH2)F$ D"s@"sCc2"sB5 A=&, HELVETICA TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN TIMESROMAN  TIMESROMAN .!)07=<C7HNHRY*_flqw&|^*)=n.lb7.iiVE ARROWS10.AL. gXOCA MATH10.AL. i4gAL LOGO24.AL. Zi HIPPO10.AL. ZLg GACHA12.AL.gY''ZMZ&ZZ YYYYYYYYYYYuYgYXYLY