DOLPHINMICROASSEMBLER9 October 1981byEdward FialaXerox Palo Alto Research Center3333 Coyote Hill RoadPalo Alto, California, 94304Filed on:[Indigo]D0Microassembler.PressSources on:[Indigo]D0Microassembler.DmThis manual describes the Dolphin microassembly language, based upon the 16 May 1979 release of theDolphin Hardware Manual, and hardware changes up to the release date of this manual.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, transmitted, disseminated, or disclosed to others inany form or by any means without prior written permission from Xerox.$JpE $>&q )p9Tr%S5q 0;!.* !,y$s&y#G %yHKySrysby8E(yDry8cJ^Dolphin MicroAssemblerEdward R. Fiala9 October 19812TABLE OF CONTENTS l.Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.Assembly Procedures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 3.Error Messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4.Debugging Microprograms . . . . . . . . . . . . . . . . . . . . . . . . . 8 5.Cross Reference Listings . . . . . . . . . . . . . . . . . . . . . . . . . . 9 6.Comments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 7.Conditional Assembly . . . . . . . . . . . . . . . . . . . . . . . . . . . .10 8.Simplified Parsing Rules . . . . . . . . . . . . . . . . . . . . . . . . . .11 9.Statements Controlling Assembly . . . . . . . . . . . . . . . . . . . .1210.Forward References . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1311.Integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1412.Repeat Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1413.Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1514.Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1515.SetTask Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1616.Assembling Data for RM . . . . . . . . . . . . . . . . . . . . . . . . . .1817.Assembling Data Items In the Instruction Memory . . . . . . . .1918.General Comments on Instruction Statements . . . . . . . . . . .2019.RM and STK Phrases . . . . . . . . . . . . . . . . . . . . . . . . . . . .2220.Cycler-Masker Phrases . . . . . . . . . . . . . . . . . . . . . . . . . . . .2321.A Phrases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2422.B Phrases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2523.ALU Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2624.Memory Reference Instructions . . . . . . . . . . . . . . . . . . . . .2725.RM Interlocking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .2826.Standalone Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3027.Branching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3028.NextData and NextInst . . . . . . . . . . . . . . . . . . . . . . . . . . .3229.Placement Declarations . . . . . . . . . . . . . . . . . . . . . . . . . . .3430.Tasking Considerations . . . . . . . . . . . . . . . . . . . . . . . . . . .3531.Microcode Overlays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3632.Recent Hardware and Assembler Changes . . . . . . . . . . . . . .36 fu!r4] HYfu ^tZr S<X M<W P<UM I<S L<Q P<O L<N# L<LX G<J L<H T<F O<E- R<Cc S<A N<? J<> ?<<8 @<:n J<8 M<6 S<5 S<3C O<1y G</ O<- N<, Q<*N K<( L<& L<$ N<#$ A< x !62F$Dolphin MicroAssemblerEdward R. Fiala9 October 198131. PreliminariesThe machine now called the Dolphin was at one time called the D0, so these two names are usedsomewhat interchangeably within this manual.The Dolphin microprogramming language is implemented as a set of definitions on top of themachine-independent assembler Micro; Micro is an Alto program, so assemblies are carried outeither on an Alto or on a Dolphin emulating an Alto. The assembly language is based upon themachine description in the 16 May 1979 release of D0 Hardware Manual and hardware changesthat have occurred up to the release date of this manual.Files referred to in this manual are as follows:DocumentationWhen Using the Assembler[Indigo][Indigo]D0Manual.PressD0Lang.McD0MidasManual.Press[Maxc2]D0Gotchas.PressMicro.Run[Maxc2]MicroD.RunMicro.PressThe assembly language is defined by D0Lang.Mc. I have tried to make D0Lang.Mc and thisdocumentation complete, so you should not need to refer to the Micro manual or study D0Lang forfurther details, except where noted here.Micro flushes Bravo trailers, so you can use Bravo formatting if you want to. However, the crossreference program, MCross, which is expected to produce primary microprogram documentation,does not handle Bravo trailers. Also, line numbers in Micro error messages may be more difficultto correlate with source statements because of the line breaks inserted by Bravo's hardcopycommand. I advise against Bravo formatting for these reasons.I recommend use of Gacha8 (i.e., a relatively small fixed-pitch font) for printing program listings,and use of Gacha10.Al for editing source files with Bravo. The smaller font is desirable becausesome statements will be long, and a smaller font will allow you to get these on one text line. Bravotab stops should be set at precisely 8 character intervals for identical tabulation in Bravo andMCross.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.I also recommend that you read the hardware manual through once or twice before programming;you will be referring regularly to the figures and tables in the hardware manual until you becomeextremely familiar with the machine. fu!r4] HYfu ^t []rG Y, V!O TVP R./ P.+PjP.`PjP4PjP N9 K0yHv #yF$s#:D 'G:Cc# :B'Gy@'G :?A ;rW :'H 8]) 4N 3 7$ 1U&; / O -> *N?% (3. &B# $\ #$ 0ysy ArK \ <% :$  =WDolphin MicroAssemblerEdward R. Fiala9 October 19814Note: All arithmetic in this manual and in Dolphin microassembler source files is in octal.2. Assembly ProceduresA microassembly is accomplished as follows:Micro/L D0Lang Source1 Source2 ... SourceNThis causes the source files "D0Lang.Mc," "Source1.Mc," ..., "SourceN.Mc" to be assembled. Theglobal switch "/L" causes an expanded assembly listing to be produced on "SourceN.LS"; if "/L"is omitted, no listing is made. The assembler also outputs "SourceN.Dib" (intermediate binary andaddresses), "SourceN.Er" (error messages, which are also printed on the display), and "SourceN.St"(the Micro symbol table after assembling SourceN.Mc).In other words, Micro assembles a sequence of source files with default extension ".Mc" andoutputs four files whose extensions are ".Dib", ".Er", ".Ls", and ".St". The default name for theseis the name of the last source file to be assembled. Direct output to particular files as follows:Micro Sys/L/B D0Lang Source1 ... SourceNcauses the four output files to be "Sys.Ls", "Sys.St", "Sys.Dib", and "Sys.Er." These four files areused as follows: The ".Ls" file is the assembly listing which you will usually not want to create--theMicroD listing file mentioned below is generally of greater value. The ".St" file is a dump of thesymbol table at the end of assembly; it can be used in subsequent assemblies to recreate theassembly environment, as discussed below. The ".Dib" file (Dolphin intermediate binary) is the filethat will be processed by MicroD later. The ".Er" file contains error messages and other assemblyinformation.A summary of local and global Micro switches is as follows:Global:/LProduce an expanded listing of the output/NSuppress .Mb file output/UConvert text in all source files to upper case/OOmit .St fileLocal:/RRecover from symbol table file/LPut expanded listing on named file/BPut binary output on named file with extension .Dib. Default symbol table (.St) and errorlisting (.Er) to named file./EPut error listing on named file/SPut symbol table on named file/UConvert text in named file to upper caseAssemblies are slow--it should take about 7 minutes to assemble a 400010-instruction program.INSERT[file] statements, described later, can be put in source files so you don't have to type asmany source files on the command line. However, this will slow assembly because each INSERTmakes a separate call on the directory lookup code (about 1 second), but all names on the commandline are looked up at once. A better shortcut is to define command files to carry out yourassemblies. fu!r4] HYfu _r.#ur Z t Vr+ySs* Pr<# N<" ML K>b Is5 FS D7U BlLx?s( :rO 90W 7fP 56& 3<03y3673yc3 >+3y3 2L 0; ,;x*s\/)\(/\'/.\%|/ x#G\/\!/"\ ?/J/\Z/\/\R/( r##vsr ^ H  ;& UV . C=[<Dolphin MicroAssemblerEdward R. Fiala9 October 19815After obtaining an error-free assembly from Micro, you must postprocess the .Dib file with MicroDto transform it appropriately for loading by Midas. This is accomplished as follows:MicroD SysMicroD displays a progress message while churning away, and requires about 60 seconds to processa 400010-instruction file (longer when large listings are produced). The local "/O" switch directs theoutput to the named file rather than to the last-named input file (default extension .Mb), so:MicroD NewSys/O Sysputs the output of MicroD for the input file Sys.Dib onto NewSys.Mb.In this example, there is only one input file for MicroD (Sys.Dib)--it is also possible to assemblesource files independently using the symbol table (.St) file produced by Micro to establish a basispoint for further assemblies, thereby reducing assembly time. For example, you can build aGlobalDefs.St file as follows:Micro/U D0Lang GlobalDefsThen do all further assemblies as follows:Micro/O/U GlobalDefs/R Sys/B Source1 ... SourceNMicroD GlobalDefs SysPreassembling D0Lang and GlobalDefs in this way might save 10 seconds of assembly time.MicroD can relocate code in IM (but not in any other memories). On very large programs, such asthe system microcode, it is possible to proceed as follows:Micro/U D0Lang GlobalDefsMicro/O/U GlobalDefs/R Source1Micro/O/U GlobalDefs/R Source2 ...Micro/O/U GlobalDefs/R SourceNMicroD Sys/O GlobalDefs Source1 Source2 ... SourceNwhere Source1 ... SourceN may assemble IM locations but must not assemble any RM locationsreferenced externally--internally referenced RM locations may be defined in Sourcex, but this has tobe done in a way that avoids assignments that conflict with other sources. In other words, forwardand external references are permitted only in instruction branch clauses, so everything else must bepredefined in GlobalDefs.St or at the beginning of a source file.One advantage of this method is that Source1 ... SourceN can be independently maintained withouthaving to reassemble the entire system for every change; another advantage is that it avoids symboltable overflow--the current system microcode is near to overflowing at present. However, manychanges to GlobalDefs will necessitate reassembling everything, and when everything is reassembledthe total assembly time will be about 9 minutes rather than 7 minutes.Note that you do not need to do anything special in your source files to declare labels which areexported (defined here, used elsewhere) or imported (used here, defined elsewhere). Micro assumesthat any undefined branch symbol is meant to be imported (but gives you the list just so you cancheck), and MicroD assumes that all labels are exported. MicroD also discards all but the last fu!r4] HYfu _r2/ ]KUxZs W;rQ UpTsUpr_ ST xPs MrD J#X HYc F[ DyBs >r*y;s0y: 7Br+, 3 V 2;y/Dsy-y,y+"y)y(`3 %rI #GK !}A" d A uK @# ,2 C KF 8) G D8( y*5 2=] Dolphin MicroAssemblerEdward R. Fiala9 October 19816definition of a name (e.g., the symbol "." is defined in every file as the address of the lastmicroinstruction).MicroD produces up to seven output files, depending upon the local and global flags specified onthe command line. The name for these files is determined as discussed earlier, followed by theextensions given below (i.e., Sys.Mb, Sys.Dls, ... , SysOccupied.Mc):.MbBinary output--data for memories and address symbols for use when debuggingwith Midas; this file is produced unless the global /P switch appears on thecommand line..DlsListing file always produced--it contains the Executive command line and allstrings printed on the display while MicroD is running (i.e., progress informationand error messages); this is followed by a table showing the number of freelocations on each page of IM, and by a list of data and address symbols in eachmemory (which can be modified by various global and local switches discussedbelow)..RegsRegister allocation listing produced if the global /R switch is specified; it lists innumerical order RM locations and address symbols associated with each..CSMapControl store map produced when the global /M switch is specified; when MicroDinput consists of a number of modules (i.e., of .Dib files), the .CSMap file willshow for each page in the control store (i.e., each page in IMX) the number ofwords in each module allocated on that page and the number of free locations inthe page..CSChartA file showing which .Dib file contained the instruction at each real address, sortedby real address; this is produced only when the global /E switch is specified and isintended for hardware debugging with a logic analyzer..absDLSA file giving the correlation between real and imaginary IM addresses, sorted byreal address; this is produced only when the global /H switch is specified and isintended for hardware debugging with a logic analyzer.Occupied.McA file which can be assembled to reserve all locations occupied by the currentimage. It contains IMReserve declarations for every location into which MicroDhas placed an instruction. The intent is that this file be used when buildingoverlays to run on top of the current image.A summary of the local and global MicroD switches is as follows:Global:/AList only absolutely-placed IM locations/CConcise listing--list everything except octal contents of IM/DDebug--print a large amount of debugging information/EProduce a .CSChart file (of Every location)/HProduce a .absDLS file (useful for Hardware debugging)/IIgnore OnPage/KKludge enable--suppress LoadPage consistency checking/MProduce a .CSMap file/NNo listing--IM contents and other memories are not listed/OProduce the Occupied.Mc output file containing IMReserve statements for all locations filled fu!r4] HYfu _rJ ]K Y8( XX VDExS< 4 Qq4 O xL )# JF  I / G? C EtL Cx@ M >Fx; = :,% 893 6o; 4x1 ,) /< .6x* ? )4 D 'i6x$a N "O . , @xs\/(\J/<\/4\B/+\/6\:/ \/5\2/\ /9\ */8$ =]>Dolphin MicroAssemblerEdward R. Fiala9 October 19817by MicroD/PPrint only--supresses all MicroD actions and just lists all .Dib files/RProduce a .Regs file/SList symbols for all memories (except Version, RVRel, Disp, IMLock, and IMMask, whichare consumed by MicroD). /N prevents /S from listing IM symbols/TTrace--print a trace of calls on the storage allocator/XExternal--allow references to unbound symbols in the .Mb fileLocal:/AList only absolutely-place IM locations--overrides global setting/CConcise listing--overrides global setting/LList everything--overrides global setting/NNot IM listing level overrides global setting/OOutput file/VVersion number/ZSpecifies scratch file to use instead of SwateeGlobal switches are usually specified on the command line as "MicroD/nmo Sys/O ..." but MicroDaccepts "MicroD Sys/O ... ~/nmo" as an alternative. This alternate form is useful with commandfiles because it allows varying switches to be specified at the end of the command line. In otherwords, if one has prepared a command file Foo.Cm containing "MicroD/n Sys/O ... ," the "~"feature allows variant switches via "@Foo ~/nmo" to the Alto Executive.Only one of the /A, /C, or /N global switches, which control additional material printed in the .Dlsfile, can be meaningful--when none of these switches is specified a verbose (/L) listing will beproduced. The /A, /C, /L, and /N local switches overrule the global switches for a particular file.The ordering of these is as follows: /L is most verbose; /A prints less IM information than /L; /Cprints all other memories but not IM; and /N prints neither IM nor other memory information.MicroD outputs a ".Mb" file, consisting of blocks of data that can be loaded into various Dolphinmemories and of addresses associated with particular locations in memories. The memories are asfollows:IM44-bit x 10000-word instruction memory(also contains 60 bits/word of placement and other information)RM20-bit x 400-word register bank memoryIn addition, three other memories called VERSION, IMLOCK, and IMMASK are produced byMicro and consumed by MicroD, but these are invisible to the programmer.There are at present very limited provisions for microcode overlays, as discussed in a later section.3. Error MessagesDuring assembly, error messages and assembly progress messages are output to both the display andthe error file.Micro error messages are in one of two forms, like the following:... source statement ...218...error message-or-... source statement ... fu!r4] HYfu/_9s\]/F\\1/\Z/O/YL@\W/6\VD/=xT\/A\R/)\Q/)\O/-\M/ \L{/ \J// Gr,2 EC D;' BI0* @~G = 40 ;AX 9wR 79* 5!; 2p4- 0G .x,s & *?x)4 & %r1# $H !D t Ar># v AyCsyy y y V>]Dolphin MicroAssemblerEdward R. Fiala9 October 19818TAG+39...error messageThe first example indicates an error on the 218th line of the source file. This form is used forerrors that precede the first label in the file. The second form is used afterwards, indicating anerror on the 39th line after the label "TAG".Note that the line count measures 's in the source, so if you are using Bravo formatting in thesource files, you may have trouble distinguishing 's from line breaks inserted by Bravo'shardcopy command.The "TITLE" statement in each source outputs a message of the form:1...title..IM.address.=.341This message indicates that the assembler has started working on that source file."IM.address.=.341" indicates that the first IM location assembled in this source file is the 341st inthe program. When a number of source files are assembled into a single .Dib file, this messagemay be helpful in correlating source statements with error messages from the postprocessor,MicroD.The most common assembly errors result from references to undefined symbols and from setting asingle instruction field multiple times (e.g., attempting to use the F1 field twice in one instruction).I do not believe that you will have any trouble figuring out what these messages mean, so nocomments are offered here.After Micro has finished an assembly, it returns to the Executive leaving a message like "Time: 22seconds; 0 errors, 0 warnings, 20007 words free" in the system window. Only when the error orwarning counts are non-zero do you have to look in the .Er file for detailed information abouterrors.MicroD errors are discussed in the appendix.4. Debugging MicroprogramsMicroprograms may be debugged directly on the hardware using facilities provided by Midas. Todebug programs you will need to load Midas and its auxiliary files as discussed in the DolphinMidas Manual.Midas facilities consist of actions to boot the Dolphin; load microprograms; set, clear, and examinebreakpoints; start, step, or halt the machine, and examine and modify storage. Addresses definedduring assembly may be examined on the display. Midas contains a command file facility thatallows you to carry out various procedures such as setting up the display and iterating through asequence of diagnostic microprograms. fu!r4] HYfuy_9s [r9( Z c XU- T+8 S8% QN MCyKs Gr~7 F\ D7/0 BlC @ =/&8 ;e@( 9Y 7 4^J 2G 0"< . +, &t #$rS !Y.0  L R2/ N :' % >S`Dolphin MicroAssemblerEdward R. Fiala9 October 198195. Cross Reference ListingsThe cross-reference program for Dolphin microprograms is a Tenex subsystem called MCross. It iseasier to maintain large programs when cross-reference listings are available, so you may wish tostore your sources on a Tenex directory and make your listings using MCross.Obviously, you can only use MCross if you have a timesharing account on Maxc. If not, you willhave to do without cross-reference listings until MCross is implemented on Alto (no one is workingon that now).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:GACHA8.EPMachine:0(selects Dolphin syntax)Action:U(convert to upper case)Action:N(read def's, no printout)File:D0LANGAction:CL(read def's, produce cross ref)File:Source1Action:CLFile:Source2Action:P(print operation usage statistics)Action:G(print global cross reference)Action:E@6. 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, forexample, put a "*" to begin a comment, the same statement will be continued on the nextline.Micro's COMCHAR feature provides one method of producing multi-statement conditionalassemblies (This method is now obsolete, replaced by the conditional assembly features discussed inthe next section). COMCHAR is used as follows. Suppose you want to have conditional assembliesbased on whether the microcode is being assembled for a Pilot or Alto-compatible configuration.To do this define "=" as the comment character for Pilot (i.e., COMCHAR[=];) and "#" as thecomment character for Alto-compatible. Then in the source files:*= Alto-compatible configuration only ...statements for Alto-compatible configuration... fu!r4] HYfu ^t []r` Y6+ WL TV%: R[ P MO1- K5yHsyGb  yF#yD#yC@#yA y@~#y? y=y<\ y:#"y9#y89y6 2t .r># ,F! * 'y$3y!}&1yFy KyI T  D BA wK F Ay s%y 3 >]nDolphin MicroAssemblerEdward R. Fiala9 October 198110*= end of Alto-compatible statements*# Pilot configuration only ...statements for Pilot configuration...*# end of Pilot statementsIn other words, "*" followed by the comment character is approximately equivalent to "%" and isterminated by the carriage return following its next occurrence.7. Conditional AssemblyD0Lang defines IF, UNLESS, ELSEIF, ELSE, and ENDIF macros for doing multi-statementconditional assemblies; IF's may be nested up to four levels deep. The syntax for these is asfollows::IF[Display]; ... statements assembled if Display is non-zero...:ELSEIF[OldDisplay]; ... statements assembled if Display is zero and OldDisplay non-zero...:ELSE; ... statements assembled if both Display and OldDisplay are zero...:ENDIF;Alternatively, UNLESS can be used instead of IF, as follows::UNLESS[Display]; ... statements assembled if Display is zero...:ENDIF;Note that each of the conditional names must be preceded by ":"; the implementation of these isdiscussed in the Micro manual. Any number of ELSEIF's may be used after an IF, followed by anoptional ELSE and a mandatory ENDIF. The arguments to IF and ELSEIF must be integers.Warning: The :IF, :UNLESS, :ELSEIF, :ELSE, and :ENDIF must be the first characters in astatement. In the following example:FlshCore::IF[MappedStorage];... statements ...:ELSE;... statements ...:ENDIF;":IF" is illegal because, due to the "FlshCore" label, ":IF" are not the first characters of astatement. fu!r4] Gfuy_9s$y]y\w)y[ WrL U@ Qt Mr(+ KC JyG?s yE4yD}yCHyAy@[Ey> ;r<y8sy70y6( 2rS 1=! /D9 +wr: *%y'Fsy%$y#$!y b r6( I  =M Dolphin MicroAssemblerEdward R. Fiala9 October 1981118. Simplified Parsing RulesAfter comments, false conditionals, and non-printing characters are stripped out, the rest of the textforms statements.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 50010 characters at any one time.If this is exceeded at any time during the assembly of a statement, an error message is output.Since horrendous macro expansions occur during instruction assembly, it is possible that instructionstatements may overflow. If this occurs, the size of the statement buffer can be expanded (Tellme.).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 the currentlocation and current memory, and as the first character of a statement to be evaluatedeven in the false arm of a conditional;","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, and tabs are syntactically meaningless (flushed by theprescan), so "T+Q" = "T + Q", each of which is a single symbol.The debugger Midas requires all address symbols to be upper case; since both Micro and MCrosshave switches that convert all source file characters to upper case, you can follow your owncapitalization conventions but must convert to upper case at assembly time using the /U switch.Experience suggests that consistent capitalization conventions are desirable, although there is notmuch agreement on exactly what conventions should be used. In this manual I follow capitalizationconventions which you may consider as a non-binding proposal. My convention is as follows:The first letter of each word is capitalized.When a symbol consists of several words run together, the first letter of each subword iscapitalized (e.g., "NextData," "StkP").When a symbol is formed by running together the first letters from several words, thenthese are all capitalized (e.g., "MNBR,"). fu!r4] Gfu ^t []rZ Yu r V!E TVB R OFNsOr MO8' KD IG G D})xAs Ex@ x>m0x<.&;eF:'x8]x6x5Ax3g 0 0rB# .M*8 ,"@ *? 'F u% r %|> #T !u%r% ;' QLxI-xAYxv'xn5!x* J ]>V%Dolphin MicroAssemblerEdward R. Fiala9 October 198112Micro builtins, memory names, and important assembly directives that should stand out inthe source, such as TITLE, END, IF, etc. are all capitals.Midas also limits address symbols to 13 characters in length; if you assemble longer addresses, youwill still be able to load and run your program with Midas, but you won't be able to examinesymbols longer than 13 characters.Also, avoid using any of the characters "=," "#," "+," "-," and "!" in address symbols; these aresyntactically significant to Midas and may cause trouble when debugging. Finally, avoid definingsymbols that end with the character "@"; the internal symbols in D0Lang.Mc by convention endwith "@," so you might have name conflicts with reserved words if you also define symbols endingwith "@."Statements are divided into clauses separated by commas, which are evaluated right-to-left. Anindefinite number of clauses may appear in a statement.Examples of clauses are:NAME,NAME[ARG1,ARG2,...,ARGN],FOO_FOO1_FOO2_P+Q+1,P+Q+1 is referred to as a "source" while FOO_, FOO1_, andFOO2_ are "destinations" or "sinks".P_STEMP,NAME[N1[N2[ARG]],ARG2]_FOO[X],Further discussion about clause evaluation is postponed until later.9. Statements Controlling AssemblyEach source file should begin with a TITLE statement as follows::TITLE[Source1];The TITLE statement:a.prints a message in the .Er file and on the display which will help you correlatesubsequent error messages with source statements which caused them;b.does a SetTask[0] (discussed later) and resets a number of assembly switches.At the end of a file you may optionally insert an END statement::END[Source1];The END statement prints a message like the title statement's and checks for unterminatedconditionals, but it does not affect the output of the assembler. fu!r4] Gfux_rK x]K: Y u+r' X> VD" Ru:r Q8u O=r5 MrP K H6ur 2 Fk7 Bx@7sx>x<#"#;$x9x89 4rD /t# ,r@y)s &srx#:'*:!6Cx:M R@ys Br? wA* 0=UDolphin MicroAssemblerEdward R. Fiala9 October 198113Note that the ":" preceding TITLE and END is optional; inserting the ":" will cause statementevaluation even in the false arm of a conditional, so an appropriate message can be printed to helpdetect :IF's unmatched by :ENDIF's. The "Source1" argument to :END is also optional.You may at any place in the program include an INSERT statement:INSERT[SourceX];This is equivalent to the text of the file SourceX.MC.The message printed on the .Er file by TITLE is most helpful in correlating subsequent errormessages if any INSERT statements occur either before the TITLE statement or at the end of thefile (before the END statement). INSERT works ok anywhere, but it might be harder to figure outwhich statement suffered an error if you deviate from this recommendation.In the event you request a listing by putting "/L" in the Micro command line, the exact stuffprinted is determined by declarations that can be put anywhere in your program.D0Lang selects verbose listing output. However, you will generally not want to print this listing.The MicroD listing is normally more useful during debugging. If you want to modify the defaultlisting control in D0Lang for any reason, you can do this using the LIST statement, as follows:LIST[memory,mode];where the "memory" may be any of the ones given earlier and the mode the OR of the following:20(TAG) nnnnnn nnnnnn (octal value printout in 16-bit units)10alphabetically-ordered list of address symbols 4numerically-ordered list of address symbols 2(TAG) FF_3, JCN_4, etc (list of field stores) 1(TAG) nnnn nnnn nnnn (octal value printout)Note: The listing output will be incorrect in fields affected by forward references (i.e., references toas yet undefined addresses); such fields will be incorrectly listed as containing their default values.Micro has a recently added TRACEMODE builtin which you may prefer to use instead of anassembly listing for the purposes of debugging complicated macros. TRACEMODE allows symboltable insertions and macro expansions to be printed in the .Er file. See the Micro manual fordetails about TRACEMODE.10. Forward ReferencesMicro and D0Lang have an extremely limited ability to handle forward references. The only legalforward references are to instruction labels from branch clauses. Anything else must be definedbefore it is referenced. fu!r4] Gfu _r@ ]K#@ [U X@yUMs Qr6 N&6 L? J\ I-J EM CO @~'ur >#< <S y:'s 6rNy4s :y2 .y1U y/ (y. & +Eurd ){<+ & D $>K "s^  t Arur& vG  L e>SDolphin MicroAssemblerEdward R. Fiala9 October 19811411. IntegersMicro provides builtin operations for manipulating 20-bit assembly-time integers. These havenothing to do with code generation or storage for any memories. Integers are used to implementassembly switches and to control Repeat statements. The operations are given in the table belowand there is some additional discussion in the Micro Manual:Set[NAME,OCT]Defines NAME as an integer with value OCT. Changes the value of NAME ifalready defined.Select[i,C0,...,Cn]i is an integer 0 to n. Evaluates C0 if i = 0, C1 if i = 1, etc.Add[O1,...,O8]Sum of up to 8 integers O1 ... O8.Sub[O1, ... ,O8]O1-O2-...-O8IFE[O1,O2,C1,C2]Evaluates clause C1 if O1 equals O2, else C2.IFG[O1,O2,C1,C2]Evaluates C1 if O1 greater than O2, else C2.Not[O1]Ones complement of O1.Or[O1,O2,...,O8]Inclusive 'OR' of up to 8 integers.Xor[O1,O2,...,O8]Exclusive 'OR' of up to 8 integers.And[O1,O2,...,O8]'AND' of up to 8 integers.LShift[O1,N]O1 lshift NRShift[O1,N]O1 rshift NOCT in the Set[NAME,OCT] clause, may be any expression which evaluates to an integer, e.g.:Set[NAME, Add[Not[X], And[Y,Z,3], W]]where W, X, Y, and Z are integers.If you want to do arithmetic on an address, then it must be converted to an integer using the IPoperator, e.g.:IP[FOO]takes the integer part of the address FOOAdd[3,IP[FOO]]is legalAdd[3,FOO]is illegalSome restrictions on doing arithmetic on IM addresses are discussed later.12. Repeat StatementsThe assortment of macros and junk in the D0Lang file successfully conceals Micro's complicatedmacro, neutral, memory, field, and address stuff for ordinary use of the assembler.However, using the Repeat builtin may require you to understand underlying machinery--in adiagnostic you might want to assemble a large block of instructions differing only a little bit fromeach other, and you want to avoid typing the same instruction over and over.Instruction statements are assembled relative to a location counter called ".". Originally set to 0 ,"." is incremented by one every time an instruction is assembled. To do a Repeat, you mustdirectly reference "." as follows:Repeat[20, . [(instruction statement)]]; fu!r4] Gfu ^t []r2+ Y-2 W'9 U<xS-xI,xGxFH#xD#xBxAR  x?  <\r Qx9s% 6Kr" 2Z 1y.Ms)y, y+  (=rJ #Gt r4*  S A _ L ;+ B "y ;s( =Z Dolphin MicroAssemblerEdward R. Fiala9 October 198115This would assemble the instruction 20 times. If you want to be bumping some field in theinstruction each time, you would proceed as follows:Set[X,0];Repeat[20, . [(Set[X,Add[X,1]], instruction statement)]];where the instruction statement would use X someplace.For a complicated Repeat, you may have to know details in D0Lang. For this you will have todelve into it and figure out how things work.13. ParametersParameters are special assembly-time data objects that you may define as building blocks fromwhich constants, RM, or IM data may be constructed. Three macros define parameters:MP[NAME,OCT];makes a parameter of NAME with value OCTSP[NAME,P1,...,P8];makes NAME a parameter equal to the sum of P1,...,P8, which are parameters orintegers.NSP[NAME,P1,...,P8];makes NAME a parameter equal to the ones complement of the sum of P1,...,P8,which are parameters or integers.The parameter "NAME" is defined by the integer "NAME!" (The "!" is a symbol constituentadded so that a constant, small constant, or RM address can have an identical NAME.), so it ok touse the NAME again as an address or constant. However, you cannot use it for more than one ofthese.14. ConstantsThe hardware allows a constant to be generated on B that is the 10-bit FF field of the instruction ineither the left or right half of the 20-bit data path with 0 in the other 10-bit byte."Literal" constants such as "322C" or "32400C" may be inserted in instructions without previousdefinition.Negative constants such as "-400C", "-32400C", etc. are also legal.Left-half-word and right-half-word constants may be constructed from integers by applying,respectively, the HiA and LoA operators to a 20-bit integer. An optional second argument to HiAshould be an integer in the range 0 to 17; if provided, this argument is or'ed with bits 0:3 of thefirst to produce the task number and high four address bits for APCTask&APC _. An exampleusing HiA and LoA is as follows:RTemp _ HiA[DispStartLoc,DispTask];*Bits 0:7 (DispTask in 0:3)RTemp _ (RTemp) or (LoA[DispStartLoc]);*Bits 10:17 fu!r4] Gfu _r#7 ]K4yZsyY)9 Ur6 RhA P- Kt H6r$9 FkTxCs (xA*#@~x>L=S! :r; 89B 6oW 4 /t ,+5 Is1xFs xEQ xC xB xA. =rZ <Ux9Ts 'x75 2t /Dr%> -zF +E ) &s'y#s  brO ys r0 R K: =UDolphin MicroAssemblerEdward R. Fiala9 October 198117Note: The TITLE statement at the beginning of a file does a SetTask[0]. fu!r4] Gfu _rC~ ^2 <!Dolphin MicroAssemblerEdward R. Fiala9 October 19811816. Assembling Data for RMRM addresses are allocated by RV statements in one of the following ways:RV[name, disp, P1, P2, ... , P7];RV[name, , P1, P2, ... , P7];RV[name, disp];RV[name];RV[name, , value];RV2[name0, name1, disp0];RV4[name0, name1, name2, name3, disp0];The first argument of RV is the "name" of the RM address to which you will subsequently refer ininstructions.The second argument "disp" is a displacement between 0 and 77. This specifies the low six bits ofthe RM address. The top two bits are determined by the top two bits of the task number, declaredby the last SetTask statement. If "disp" is omitted, the RM address is allocated at the last locationplus 1.The remaining 7 arguments are parameters or integers summed to determine the value loaded intothat location. If all of these are omitted, then the location will be uninitialized.RV2 and RV4 macros allow definition, respectively, of two consecutive or four consecutive RMlocations. The first two (four) arguments are the names of the consecutive registers, and the finalargument is the displacement of the first named register (0 to 77); no provision is made forassembling values into registers defined this way. It is convenient to define registers with RV2/4rather than one-at-a-time, when they are constrained to be consecutive by some usage. Forexample, target registers for PFetch2/4 should be defined by RV2/4.Avoid assigning useless initial values to variables because this will prevent the "Compare" functionin Midas (which compares the microstore image against what you loaded) from reporting fictitiouserrors. In a system microprogram (as opposed to a diagnostic), any occurrence of a variable with aninitial value is probably a programming error since it requires reloading the microcode to restore theinitial value. Hence, you probably should initialize such registers with your program.Also, boot microcode does not allow any memories except IM to be initialized from the boot EPROM, andcurrent software for loading microcode overlays is also limited to IM. For these reasons the usual practice isto put code for initializing RM into a "throwaway" page which can be overwritten by something else after itis executed.The hardware imposes a number of strange constraints upon RM placement. For example,addresses used as base registers must (usually) be even, addresses for PFetch4/PStore4 must(usually) be origined 0 mod 4, and addresses for PFetch2/PStore2 must (usually) be at evenlocations (exception: stack double-words). Also, RM is partitioned so that only locations 0 to 77 areaccessible to tasks 0 to 3, 100 to 177 to tasks 4 to 7, 200 to 277 to tasks 10 to 13, and 300 to 377 totasks 14 to 17. Tasks 1 to 3 in each group of 4 are further limited because the task number isOR'ed into high address bits in various ways. These constraints will be a source of many programbugs. fp!q4] Gfp ^r []qIxXs!xVxUMxSxQxPWxN' Kaq)7 I F$:( DZM BG @ =S;# ;U 8Y 6KO 4/- 29* 0@ /!C +E )U (?% &O'? $Wy!YseyG(yD'y7 qG %6 SE f &A D )-4 ^ z =ZDolphin MicroAssemblerEdward R. Fiala9 October 198119You must be careful to assign a "disp" that satisfies all the uses of each RM address. If you screwup, the assembler will indicate an error when you illegally reference the RM location in aninstruction.Note: Suppose that you want tasks 10, 11, 12, and 13 to share a section of microcode but useindependent RM locations. Then you do a SetTask[10] before that section of the program, and youallocate a block of RM locations in the range 100-117 and refer to these locations in the program;you also allocate parallel blocks of RM locations in the ranges 120-137, 140-157, and 160-177 foruse by tasks 11, 12, and 13, respectively. In this way, the program will do what you want. If thefour tasks have some other RM locations that are shared, allocate these in the range 160-177, so thatthey will be accessible to all four tasks.Sometimes you may want to use several different names to refer to the same RM location. To dothis, define the first name with RV, as above; you can then define synonyms in several ways, one ofwhich is as follows:RM[FOO1, IP[FOO]];This defines the address FOO1 at the same location as the (previously-defined) address FOO.17. Assembling Data Items In the Instruction MemoryIf you do not want to clutter RM with infrequently referenced constants or variables, and if you arewilling to cope with the hardware kludges for reading/writing the instruction memory as data, thenyou can store data items in IM.To assemble a table of data in the instruction memory:Set[T1Loc,100];IMData[(TABLE1: LH[P1, ... , P8] RH[P1, ... , P8], At[T1Loc])];IMData[(LH[P1, ... , P8] RH[P1, ... , P8], At[T1Loc,1])];...where TABLE1 is an IM address symbol equal to the location of the first instruction in the table,P1, ..., P8 are parameters or integers. LH stores the sum of up to 8 parameters in the left-half ofthe IM word and RH, in the right-half; these macros do not allow you to specify the remainingfour bits of the 44-bit instruction--the assembler will ensure that the data has valid parity by storinga 0 or 1 in the low-order bit of the RX@ field (which is one of the four bits you cannot specify)."At" is discused in the "Placement" section later. fp!q4] Gfp _q5/ ]K"9 [ Xpq)/ VDX TyB Ra PG OH MO* I> H` FHxCs @7qK ;Ar4 7q^ 6W 4: 06x.sx,?x+E9x) &qG $=' #] !6C% kM 2 Z>JDolphin MicroAssemblerEdward R. Fiala9 October 19812018. General Comments on Instruction StatementsThe general forms of an instruction statement are as follows:TAG:branch clause, T_rmaddr_(A phrase) and (B phrase), function, placement;TAG:branch clause, T_A phrase, B phrase, function, placement;TAG:branch clause, A phrase, RMAddr_B phrase, function, placement;-or-TAG:branch clause, PFetch1[rbase, rdest, f2], placement;TAG:branch clause, PFetch1[rbase, rdest], f2, placement;where the first three examples are "regular" instructions and the last two, "memory reference"instructions.Rule: TAG is an optional IM address symbol or label; it must appear first in the instructionstatement.TAG may be referenced from branch clauses in other instructions, as discussed in the "Branching"section, and it will appear in the output file for use in debugging.Rule: Clause order is totally arbitrary; it doesn't matter which ones appear first in the statement.However, you might wish to follow a consistent ordering convention for program readability.Placement clauses, A phrases, B phrases, ALU clauses, and memory reference clauses are discussedin separate sections and only outlined here.The ALU operation in the first example is a function of both H1 and H2; it involves only H1 inthe second, and only H2 in the third. In this manual, the H1 and H2 data paths are referred to as"A" and "B," respectively, and the output of the ALU, loaded into H3P, is referred to as "LU."Rule: In an ALU operation involving both A and B, the A phrase must appear to the left of the Bphrase.Rule: An F1 or F2 function that either sources or sinks A will appear in the A phrase; one thateither sources or sinks B will appear in the B phrase; one that involves neither A nor B will appearas a separate clause in the instruction.Data-routing clauses have one or more "_"'s in them and require parentheses in some places tocause evaluation in the correct order. One of these clauses is evaluated from right-to-left, or from"sources" to "sinks."If there is only one source and one sink in the clause, no problem: simply write "sink_source",e.g.:T_RMAddr,The assembler figures out how to route data from the RM addressRMAddr onto A, through the ALU, and into T.RMAddr_34C,Again the assembler figures out how to construct the constant 34, route itonto B, through the ALU, and into the RM address RMAddr. fp!q4] Gfp ^r/ []q=yXs(GyW;(9yU(>TyyS(4yQ(4 Niq"< L I-tqH Gb CT B%D >tqG <A 9w@ 7, 4:@ 2p)9 0I -3tq[ +i 'tqA &,] $a( K %e Z #= x\s!4 !+xT !4!8 N >W;Dolphin MicroAssemblerEdward R. Fiala9 October 198121When you have A or B phrases embedded in ALU expressions, then you have to use parentheses,e.g.:T_(StkP_RMAddr)+1,The assembler routes RMAddr onto A, loads StkP from A with an F2function, selects the A+1 ALU operation, and sets the LT bit in theinstruction so that T will be loaded from the ALU.T_(LoadTimer[RMAddr])+(SALUF_T)The assembler routes RMAddr onto A, selects the LoadTimer function inF1, routes T onto B, selects the SALUF_ function in F2, selects the"A+B" ALU operation, and sets the LT bit to load T from the ALUoutput.In assembling the first clause above, the assembler proceeds in the following way:a.RMAddr is looked up first and recognized as an RM address. Error checks ensurethat RMAddr can legitimately be referenced by the current task. If so, the propervalue is assembled for the RSel, RMod, RX, and MemIns fields of the instruction.The assembler's macros leave a neutral symbol "RB" at the end of this evaluation tocheck for routing errors later.b."StkP_" is looked up next; this macro expands to store the correct code in the F2field of the instruction and leaves a neutral symbol "A_" to check for routing errors.c."A_RB" is looked up; because routing RB onto A is legal, this "connection macro" isdefined and expands to leave the neutral "A." (If the routing had been illegal, thenMicro would have printed an error message like "A_RB undefined.")d."A+1" is looked up; this macro expands to store the correct code in the ALUFinstruction field and leaves behind the neutral symbol "LU" to check for routingerrors.e.Then "T_" is looked up; it is a macro that expands to store a 1 into the LT field ofthe instruction, leaving the neutral "LU_."f.Finally, "LU_LU" is looked up; it is a "connection" macro that does nothing andleaves behind the neutral "LU"; since there is no more text in the clause this finalneutral is thrown away.Note: The "()" in the first example above are not optional. If you omit them, the assembler wouldlook up "RMAddr+1", which would be undefined.One general idea in the above is that at each stage the source is routed only as far as necessary toload it into the destination.Note:T_StkP_RMAddr,is legalT_StkP_(RMAddr),is legalT_(StkP_RMAddr),is legalStkP_T_RMAddr,is illegal fp!q4] Gfp _qB ]KxZs! 3!Y)&!W2xV!!T 8!S_#!Q+!P MOqRxI:<:H9:FH5:D}S:Bx?A:-$:=v>x::1":89-(:6oAx2:4:12;:/hx+:=:*++x&:?:$;:#$ pq? - uQ xus !!(! !  =VgDolphin MicroAssemblerEdward R. Fiala9 October 198122The last clause above is illegal because, by the time the assembler recognizes StkP_, it has alreadyrouted the source data past A and through the ALU, and there is no path from the ALU to StkP.The assembler is not clever enough to remember that the data originally started on A.Here are some more "()" examples:T_(RMAddr)+T,is legal--"()" are required around RM addresses in combination withother stuff.T_RMAddr,is legal--"()" optional around an RM address all by itselfT_(RMAddr)+(T),is legal--"()" optional around "T."T_((RMAddr)+T),is legal--extra "()" around an entire source always OK(T_(RMAddr)+T),is legalT_T+(RMAddr),is illegal--you cannot reverse the A and B phrases.RMAddr_(RMAddr)+(2C)is legal--"()" required around constants in combination with other stuff.The last two examples at the beginning of this section show the form of "memory reference"instructions. In the first example, the F2 field is used instead of T to specify the displacement forthe reference; in the second example, T is used as the displacement so F2 is available to specifysome function. Memory reference clauses are discussed later.19. RM and STK PhrasesThe hardware complicates RM references by providing only six bits of RM address in theinstruction. The remaining two address bits come from the task number. The programmer mustdeclare the task number with SetTask before any references.RM addresses can source A and can be used in ALU phrases. In this case, the RM address has tobe enclosed in "()."RM addresses can be used as sinks for ALU operations and ALU sources (which the assemblerroutes through the ALU). For these simply write the register name followed by "_".Some examples of clauses involving RM are as follows:RMAddr_(RMAddr)+TUse in an ALU expression and as a sink.RMAddr_TThe assembler automatically routes T through the ALU and intoRMAddr.PCF[RMAddr]_PCF[RMAddr]You really mean RMAddr_PCF[RMAddr], but due to the vagaries ofthe assembler you write it this way.T_(PCF[RMAddr])+TUse with cycler-masker operation PCF.T_PCF[RMAddr]+T"()" not mandatory with these.T_RMAddr"()" optional when RMAddr not combined with other text.DB_RMAddrUse with an A sink.T_(SB_RMAddr)+TUse with an A sink inside an ALU operation.The assembler will detect all illegal RM references. In other words, if the RM word isunaddressable by the currently selected task, or if it is required to be even or quadaligned, theassembler will check for this and indicate any error. fp!q4] Gfp _q04 ]K] [U X!xUMs !C!S xRE!:xP!#xN!6xMO!xK !3xJ!< FqG DQ CV AR= <\r 8qD 7\ 5U; 1$: 0 ,D *S 'i5x$s!'x#!,!!x!;!$x!%xI!x!7x!xS!+ qH :E o5 (>XDolphin MicroAssemblerEdward R. Fiala9 October 198123References to the stack always read the word pointed to by StkP, then adjust the stack pointer inthe ways discussed in the "A Phrases" section; if the stack is written, the modified address is usedfor the write. The various Stack terms may be used interchangeably with RM addresses where theyare legal. Also note the following:Stack&+1_(Stack&+1)+Tis legal.Stack&+1_(Stack)+Tis illegal.The last example is illegal because you must use the same StkP modifier in both read and writeparts of the instruction.Occasionally you may wish to create a constant whose value is an RM address. To do this you canuse the following kludge:B_IP[RMAddr]CThis puts a constant whose value is the address of RMAddr onto B.20. Cycler-Masker PhrasesThe semantic cycler-masker operations, operating on RM data, are as follows:LSh[RA, n]Left shift the RM address RA n positions (n = 1 to 17).RSh[RA, n]Right shift RA n positions (n = 1 to 17).LdF[RA, pos, size]Right-justify or load an arbitrary field from RA; POS is the left bit of the field andSIZE is the number of bits in the field.RCy[RA, n]Right cycle RA n positions (n = 1 to 17).LCy[RA, n]Left cycle RA n positions (n = 1 to 17).Dispatch[RA, pos, size]Loads APC with any field of size less than 4 bits from RA; the following instructionmust contain a Disp control clause to carry out the dispatch to the location atPage[0:3],,JA[0:3],,APC[14:17].RHMask[RA]= RA & 377.LHMask[RA]= RA & 177400.Zero= 0.FixVA[RA]= RSh[RA,1] & 40100.Formn[RA]= RA & n (n = 0 to 10).Form-n[RA]= RA & -n (n = 2 to 10).Nib0Rsh8[RA]= RSh[RA,10] & 360, which is the first 4-bit nibble in RA right-shifted 10.For these operations, the assembler fabricates values for F1, F2, and BSel to cause the appropriateshift and mask. RA may be any normal RM address or one of the special ones that have RMod=1and don't use F1 or F2 in their specification.In addition to the cycler-masker phrases discussed here, the various forms of the NextData andNextInst functions discussed later use the cycler-masker to extract either the left or right byte fromthe selected RM word. fp!q4] Gfp _qV ]K>& [U Y$xVs!xUM! QqC P4 L%; JxH6s DqA ?r <qLx9s 3x7 $x6( A4(x2 $x12 $x/hK. A,x*  x)  x'Fx%|x#x! x  K q.5 %7 8. 2, f 1P =V!Dolphin MicroAssemblerEdward R. Fiala9 October 19812421. A PhrasesAll of the A sources use the RMod and RSel instruction fields; some also use the F1 and F2 fieldsin conjunction with these. An A source can be any of the following:ADummy source for clause splitting. It indicates that the source for some sink is ALUA(You should never need to use this because normally the ALUA sink and source are writtentogether separated by "_" or the ALUA source is embedded in the ALU phrase.).RAddrAn RM address.StackRM addressed by StkPStack&-nRM addressed by StkP; StkP_StkP-n (n = 1, 2, or 3) after the read (and before the write,if any).Stack&+nRM addressed by StkP; StkP_StkP+n (n = 1, 2, or 3) after the read (and before the write,if any).PCF[RAddr]RAddr must be quadaligned--i.e., its low two address bits must be 0.SB[RAddr]RAdr must be quadaligned.DB[RAddr]RAdr must be quadaligned.NextInst[RAddr]Instruction dispatch; incorporates both the NextInst F1 function and the PCF[RAddr] cyclermasker operation, so RAddr must be quadaligned. See the "NextData and NextInst"section.CNextInst[RAddr]Like NextInst; see the "NextData and NextInst" section.NextData[RAddr]Incorporates both the NextData F1 function and the PCF[RAddr] cycler masker operation,so RAddr must be quadaligned; see the "NextData and NextInst" section.CNextData[RAddr]Like NextData; see the "NextData and NextInst" section.BBFA[RAddr]Also a dispatch (no special restrictions on RAddr); uses F1 and F2.BBFB[RAddr]Uses F1.WFA[RAddr]Uses F1.WFB[RAddr]Uses F1.RF[RAddr]Uses F1.BBFX[RAddr]Uses F1.The A sources below use RMod and RSel to specify external R-bus sources and use the cycler-masker to extractindividual registers from multi-field sources.GetRSpec[n]Used to place a multi-field word on A. n is a 7-bit value whose leading bit is placed inRMOD and next 6 bits in RSEL. You should normally prefer to use one of the explicitmacros given below instead of GetRSpec[n].SStkP&NStkP= GetRSpec[103] SStkPSaved StkP; uses F1 and F2. NStkPStkP (ones comlemented); uses F1 and F2.ALUResult&NSALUF ALUResultUses F1 and F2. NSALUFUses F1 and F2.MemSyndromeMemErrorCycle&PCXF= GetRSpec[127] CycleControlUses F1 and F2 (= DBXReg..MWXReg) DBXRegUses F1 and F2. MWXRegUses F1 and F2. PCXRegUses F1 and F2 PCFRegUses F1 and F2.PrinterUses F2.Timer= GetRSpec[133] fp!q4] Gfp ^r []qC YDxVs/9/UpB/T;xRh/ xP/xO/C/MxL/ L/JxH /DxFk/xD/xC/7#/A4/@[x>/7x= /=/;Fx:/7x7f /Cx5 /x4 /x2p /x0/x/! /x,Px+".x( /J/'#T/%*x$ /x"s/x /$x%x} / x/ x/ xx /x9 /x / x / xC/ x/ x /x M/  *=\iDolphin MicroAssemblerEdward R. Fiala9 October 198125DBSBUses F2.RS232MNBRUses F2.APCTask&APC= GetRSpec[143] APCTaskUses F1 and F2. APCUses F1 and F2.APC&APCTask= GetRSpec[143] (synonym)CTask&NCIA CTaskUses F1 and F2. NCIAUses F1 and F2 (= CIA ones complemented).CSDataPage&Par&Boot= GetRSpec[157] PageUses F1 and F2. ParityUses F1 and F2. BootReasonUses F1 and F2.Rule: Those of the above sources that accept a normal RM address as an argument, namelyPCF[RA], SB[RA], DB[RA], WFA[RA], BBFB[RA], WFB[RA], RF[RA], and BBFBX[RA], requirethat this same form be used when writing RA in the same instruction; i.e.:PCF[RMAddr]_(PCF[RMAddr])+Tis legalRMAddr_(PCF[RMaddr])+Tis illegalThis unfortunate kludge is required because PCF[RMAddr] will set RMOD to 1, while RMAddr_will set RMOD to 0, causing an assembly error.Sinks for A are the ALU and a number of other registers selected by functions. A sinks can be anyof the following:any ALU expression or ALU sink (T_, RAddr_, or LU_)A_No-op sink--simply routes the selected A source onto ALUA.APCTask&APC_Uses F1 and F2Restore_Uses F1 and F2StkP_Uses F2CycleControl_Uses F2SB_Uses F2DB_Uses F2MNBR_Uses F1 and F2PCF_Uses F1 and F2Printer_Uses F221. B PhrasesB sources can be any of the following:BDummy source for clause splittingConstantsUses FF--see earlier constant sectionT fp!q4] Gfpx_9s/x]x[/xZC /xX/ xV/ xUM /xS xQ/ xPW/%xNxM /xKa/ xI/ xH / Dtq? BK A.Jy>s&y<& 9Tq+. 7. 4Q 2Lx/s3x-/:x,< / x*/ x(/x'F /x%/x#/x"P/ x / x/ /r q&xs~!xT~%x2 =WDolphin MicroAssemblerEdward R. Fiala9 October 198126B sinks can be any of the following:B_No-op destination--simply routes source onto B.RS232_Uses F1SALUF_Uses both F1 and F2.CTD_Uses both F1 and F2.any ALU expression or ALU sink23. ALU ClausesIn the ALU operations given below, the "A" and "B" components may be any A and B phrases,respectively:BAA and BA or BA xor BA#BA and not BA or not BA xnor BA=BA+1A+BA+B+1A-1A-BA-B-1A SALUFOP BRule: For all ALU operations except the "A" and "B" operations, the A phrase must always beenclosed in "()"; the B phrase must be enclosed in parentheses unless it is T; "()" are optionalaround T.You must not, for example, write "A and not B" as "A and (not B)"; in other words, it is illegal toput random "()" in the name of the ALU expression, even though that may clarify the meaning. Ifyou tried to do this, the assembler would fail to recognize "not B" and flag an error. The "()" areonly legal around the "A" and "B" parts of the ALU phrase.The arithmetic operations, "A-1," "A+1," "A+B," "A+B+1," "A-B," and "A-B-1" may optionallybe accompanied by the standalone clause "UseCOutAsCIn," which causes the ALU carry-in to bethe carry-out of the last ALU operation for the same task. The value of the carry-out may befrozen across instructions by means of the FreezeResult standalone function."UseCOutAsCIn" cannot be used with the "A" operation because the logical rather than the arithmetic formof the "A" operation is used by the hardware.Legal sinks for ALU phrases are:RAddr_Any RM address fp!q4] Gfp _q$x\Ts~/xZ~xY~xW^~xU Pr Mrq"7 K yHsyGyF$yDyCcyB y@ y?Ay=y<y;y9y8]y6y5 2Ltq? 0>" . +E4/ ){>" 'L %: "s8" U M LyRsHy- qxs!  =UMDolphin MicroAssemblerEdward R. Fiala9 October 198127Stack_Stack sinksStack&+n_Stack&-n_T_LU_This null sink is necessary when the ALU operation must be "A" or "B"for a subsequent branch condition or to interlock/not interlock an RMreference, even though no real destination is being loaded with the ALUoutput.Here are some examples of ALU clauses:T_(RAddr)+T"()" optional around T, mandatory around RAddr.T_RAddr"()" optional around RAddr uncombined.T_(RAddr)also ok.RAddr_(RAddr) xor (377C)"()" mandatory.RAddr_T_377C"()" optional when constant uncombined.T_RAddr_(377C)also ok.24. Memory Reference InstructionsMemory reference instructions have a different form from regular instructions, as discussed in thehardware manual. Branch and placement clauses are identical to those in regular instructions, andthe F2 clause, if any, is identical to that in a regular instruction. The rest of the instruction is asingle clause in one of the following forms:PFetch1[RBase, RAddr<, F2>]OddPFetch1[RBase, RAddr<, F2>]PFetch2[RBase, RAddr<, F2>]OddPFetch2[RBase, RAddr<, F2>]PFetch4[RBase, RAddr<, F2>]OddPFetch4[RBase, RAddr<, F2>]PStore1[RBase, RAddr<, F2>]OddPStore1[RBase, RAddr<, F2>]PStore2[RBase, RAddr<, F2>]OddPStore1[RBase, RAddr<, F2>]PStore4[RBase, RAddr<, F2>]OddPStore1[RBase, RAddr<, F2>]IOFetch4[RBase, Device<, F2>]OddIOFetch4[RBase, RAddr<, F2>]IOFetch20[RBase, Device<, F2>]OddIOFetch20[RBase, RAddr<, F2>]IOStore4[RBase, Device<, F2>]OddIOStore4[RBase, RAddr<, F2>]IOStore20[RBase, Device<, F2>]OddIOStore20[RBase, RAddr<, F2>]XMap[RBase, RAddr<, F2>]OddXMap[RBase, RAddr<, F2>]Input[RAddr<, F2><,OtherRAddr>]Output[RAddr<, F2><,OtherRAddr>]ReadPipe[RAddr<,F2><,OtherRAddr>]Refresh[RAddr]IOStore16, OddIOStore16, IOFetch16, and OddIOFetch16 are synonyms for IOStore20,OddIOStore20, IOFetch20, and OddIOFetch20, respectively.In these clauses, "RBase" is an RM address subject to the same constraints as an RM reference in aregular instruction; i.e., it must be in the group of 100 accessible to the current task and must notbe in the subrange 0-17 of that group unless the task selected by SetTask is 0 mod 4; in addition, itmust normally be an even address, as discussed in the hardware manual. When it must be even,you write, for example, "PFetch1[ ... ]"; in the rare case when it must be odd, you write"OddPFetch1[ ... ]." Also, the various forms of RM addressing that require RMod=1 cannot beused when specifying a base register (i.e., Stack, Stack&+n, Stack&-n, PCF[..], SB[..], and DB[..] fp!q4] Gfpx_9s! x]x[xZCxX!: !W;!$!U.!Ty Q+q&xNis !/xL!&xK!xIs! xG !'xF$ ! ARr" =qE <Q :KJ 8,x5s# x4# x2p# x0# x/!# x-z# x+# x*+# x(# x&# x%5#  x#x!x ?!x Iq}4~ ~8  5- B23 w>' T 5$ Y Mb =]LDolphin MicroAssemblerEdward R. Fiala9 October 198128won't work); this is illegal because the DF2 bit in memory reference instructions coincides withRMod in regular instructions.When the optional F2 argument is omitted, the displacement relative to the base register is takenfrom T, and you may use F2 for an unrelated function in a separate clause. If you supply the F2argument, which must be an integer less than 20, that value is stored in the F2 field of theinstruction and used instead of T. See the hardware manual for details on how this works.Note that memory instructions use the ALU to add the low-half base register to the displacement;the result of this addition may be tested in the next instruction if desired. For example, it issometimes useful to branch on the ALU carry in the next instruction, so that the high part of thebase register can be updated when crossing a 64K memory boundary.Input, Output, and ReadPipe references do not use a base register, but address computation is donejust as for other references. "OtherRAddr" (default 0 if omitted) specifies the base register, whichcan be tested by an R<0 or R Odd branch condition in the same instruction, or used to somehowsetup an ALU result for a branch condition in the next instruction. In addition, if the base registeris the target of an immediately preceding PFetch, then the Input or Output will be held until thatreference has finished; specifying a different base register avoids this unnecessary hold--or you candeliberately select the target of the preceding PFetch to interlock the reference.The RAddr argument may be either "Stack" or an RM address accessible to the task. Since thecurrent task is OR'ed into the top 4 bits of the 8-bit SrcDest field that specifies RAddr, RAddr isfurther constrained to satisfy the relation: (RAddr or (CTask lshift 4)) = RAddr. In addition,RAddr must not be 0 (which is the value assembled for "Stack"); for PFetch2/PStore2 it must beeven and for PFetch4/PStore4 it must be quadaligned."Must be even" and "must be quadaligned" are a little too strong. If you violate this rule,the assembler will print a warning message which you are free to ignore. In this case, thehardware will transfer the double-word/quad-word into the two/four RM locationsbeginning with the one you specify and wrapping around at 20-word boundaries (i.e., ifyou specify RM 36 as the address for a PFetch4, the data will be delivered to 36, 37, 20and 21). The reason for the warning is that RM interlocking will not occur correctly, asdiscussed in the next section.25. RM InterlockingThe hardware "interlocks" RM references to ensure that following a memory reference you neitherread an RM word before the memory controller has filled it from storage nor overwrite an RMword before the memory controller has deposited it in storage; an instruction will be repeatedlyaborted and reexecuted until it is safe to proceed. However, the hardware interlock is notfoolproof, so there are some programming requirements of which you must be aware.First, every instruction is reading some RM word (word 0 in the current 100-word region, if youdon't explicitly mention an RM address), but the hardware interlocks reads only when the ALUoperation involves A somehow--no interlock occurs on an LU_T ALU operation, which does notinvolve A. However, sometimes you will utilize an RM word without routing it into the ALU. Forexample: fp!q4] Gfp _q T ]K Y)8 XB VDM Ty> Q)7 O= T Mr2/ KA H6F FkH DR BQ A b ?AN =vR :S 89N 6o6) 4D 24y/Dy.M8#y, By*&0y)W@y'<y&  !r qC A  %; A3( vQ ;$ :0, oV J  b =\x9Dolphin MicroAssemblerEdward R. Fiala9 October 198129StkP_RAddr, RAddr_T;Load an A destination from RAddr, LU_TRAddr, Skip[R Odd];Use the R<0 or R Odd branch conditionsIn these situations, if RAddr is involved in a preceding fetch-type memory reference (PFetch1/2/4,ReadPipe, XMap, or Input) which is still in MC1/MC2, the hardware interlock will not occur andthe instruction will erroneously proceed without waiting for the memory controller to fill the wordfrom storage.The assembler has some features to help avoid programming errors in this situation. First, thedefault ALU operation in an instruction is LU_T, but when you write a clause which loads some Adestination from RM, the default is changed to LU_A which will invoke the read interlock. Inother words:StkP_RAddr;= LU_StkP_RAddr, so the interlock will occurA_RAddr;= LU_A_RAddr, so the interlock will occurRAddr, Skip[R Odd];didn't say A_RAddr, so LU_T is still the default and interlock willNOT occur--potential undetected programming error here.StkP_RAddr, RAddr_T;LU_A default overruled by LU_T, so no interlock will occur, but theassembler will issue a "No register interlock" warning to you in this case;you can ignore the warning if you want to, but...StkP_RAddr, RAddr_T, NoRegILockOK;suppresses the "no register interlock" warning message; you should addthe "NoRegILockOK" clause to instructions which do not invoke theregister interlock if you are sure that not having the register interlock isok.Another set of potential problems occurs when the two RM words involved in PFetch2/PStore2 arenot an even-odd pair or when the four RM words affected by a PFetch4/PStore4 are notquadaligned (i.e., the first of the four words does not have two low zeroes in its address). Forexample, suppose a PFetch2/PStore2 is made to the Stack; if the first of the two RM words is even,all is well and the hardware interlock will abort references to either of the two words involved inthe reference; however, if the first of the two RM words is odd, then the hardware will NOT abortreferences to the second word involved in the reference (It will instead erroneously abort referencesto the RM word preceding the first word). Similar problems occur when the first RM word of aPFetch4/PStore4 is not quadaligned.To assembler will flag potential problems in these situations with a warning message "WARNING:RAddr not even" on a PFetch2/PStore2 or "WARNING: RAddr not quadaligned" on aPFetch4/PStore4 for which the RM address is not aligned. These warning will not occur onPFetch2/PStore2 to the stack. If an unaligned reference is legitimate, then you must advise theassembler by placing an "OddOK" or "NonQuadOK" clause to the right of the reference.When you reference a stack word that is potentially the second word of an unaligned andincomplete PFetch2, you have to be very careful to use the Stack&-n form of reference; when youwrite any stack word that is potentially the second word of an unaligned and incomplete PStore2,you must use the Stack&+n form of reference. Also note that when you interlock by usingStack&-n or Stack&+n, you do not have to route the stack through the ALU to accomplish theinterlock. These are discussed in the hardware manual. fp!q4] Gfpx_9s!"x]!# ZCqZ XxL VC T Qq'8 O T M] L xIPs !,xG!)xF!*!D7xB!+!A@ !@71x>"!=/; !;=!:n? !9  5q P 3T 2)O 0_\ .?$ ,a *7. )4P 'i# #2, "-H b+. \ @ [8?[ : !+:" 63:o  k" ! 1(2 f7 =WqDolphin MicroAssemblerEdward R. Fiala9 October 19813026. Standalone FunctionsThe following summarizes standalone functions, each written as a separate clause in the instruction:BreakPointCauses the instruction to be breakpointed by Midas when debugging.NopAssembles a no-op instruction.SpareFunctionUses F1 and F2 (undefined)ResetErrorsUses F1 and F2IncMPanelUses F1 and F2ClearMPanelUses F1 and F2GenSRClockUses F1 and F2ResetWDTUses F1 and F2BootUses F1 and F2SetFaultUses F1 and F2ResetFaultUses F1 and F2UseCTaskUses F1 and F2WriteCS0&2Uses F1 and F2WriteCS1Uses F1 and F2ReadCSUses F1 and F2D0OffUses F1 and F2RegShiftUses F2 (ordinarily not written explicitly becuase the sources that requireit are individually named, so you probably will never use this)FreezeResultUses F2IOStrobeUses F2ResetMemErrsUses F2UseCOutAsCInUses F2SkipDataSee the "NextData and NextInst" section.CSkipDataSee the "NextData and NextInst" section.LoadPage[n]Uses F1 and F2; 0 <= n <= 17, where n is an integer equal to thepage number; this is used when an ordinary branch clause is used in thenext instruction.LoadPageExternal[n]Like LoadPage; this must be used when the branch clause in the nextinstruction is a GotoExternal or CallExternal.At[n1,n2]See the "Placement Declarations" section.Opcode[n]See the "Placement Declarations" section.27. BranchingThis section discusses branch and dispatch clauses, which are assembled into the JC and JA fields ofthe instruction. At assembly time, D0Lang produces the correct JC field and sometimes the correctJA field or correct low bit of JA; however, most branch clauses indicate the required branchlinkages in extra fields assembled only for MicroD. MicroD then determines a satisfactoryplacement for the instructions and fills out JA correctly.The hardware defines GoTo, Call, Disp, Return, and conditional GoTo, each represented by codesin the JC instruction field; conditional GoTo's may specify any of eight branch conditions usingonly JC and JA or 6 more branch conditions using F2. The least significant bit of JA is used tomodify the branch condition on a conditional GoTo and to modify the action of a Return. fp!q4] Gfp ^r []q.6xXs !7 xV!xUM !xS ! xQ! xPW ! xN ! xM! xKa! xI! xH ! xFk! xD ! xC! xAu! x?! x>&!2!<?x; !x9w!x7 !x6( !x4!(x2!(x12 !/!/8!.qx,!>!+i.x)!)x(!) #Gr qN  L @": u"8 : 9 R nZ O 8h =Xy3Dolphin MicroAssemblerEdward R. Fiala9 October 198131The assembly language encodes these possibilities in the following kinds of branch clauses:DblGoTo[t1, t2, bc]Jumps to t1 if the branch condition bc is true, else to t2; MicroD willplace t2 at an even location and t1 at the adjacent odd location; thetargets must be on the same 400-word microstore page as the instructioncontaining the DblGoto.GoTo[t1<, bc>]Jumps to t1 if the optional bc is either omitted or true, else falls throughto the next instruction inline. t1 will be placed on the same page as thecurrent instruction. If bc is given, the next instrucion inline will beplaced at an even location and t1 at the adjacent odd location.Skip[]= GoTo[.+2<,bc>]Call[t1]Loads TPC[current task] with the address of the next instruction inlineand branches to t1; MicroD will place the next instruction inline at (. &7760)+(.+1 & 17) and will place t1 on the same page.CallX[t1]Loads TPC[current task with (. & 7760)+(.+1 & 17) and branches to t1.The next instruction inline is not constrained to lie at any particularlocation; MicroD will place t1 on the same page.Disp[t1]Will dispatch to the the table origined at (t1 & 7760); the programmermust manually place all instructions in the dispatch table with At clauses.The dispatch will transfer control to (t1 & 7760) OR'ed with the lowfour bits of APC. The instruction immediately preceding Disp mustnormally be a Dispatch (but conceivably UseCTask or APCTask&APC_might be used instead of Dispatch in some clever situations).ReturnReturns to the address in APC (JA.7=0).NIRetReturns to the address in APC (JA.7=1) which will contain2001+(4*ByteCode); this form of return is used after NextInst.TaskSpecial kludge that does Call[.+1] in the current instruction and forces aReturn in the next instruction inline (which must not have any branchclause); the second instruction inline will be placed at .+1.GoToExternal[n]Puts a goto code in JC and stores the integer n in JA; no placementconstraints imposed and no error checking; usually used afterLoadPageExternal[m].CallExternal[n]Puts a call code in JC and stores the integer n in JA; no placementconstraints imposed and no error checking; usually used afterLoadPageExternal[m].DblGoToP[t1, t2, bc]= DblGoto with the on-page constraints removed; the precedinginstruction must contain an apropriate LoadPage; no error checking.GoToP[t1, bc]= Goto with the on-page constraint removed.CallP[t1]= Call with the on-page constraint removed.DispP[t1]= Disp with the on-page constraint removed.SkipP[t1]= Skip with the on-page constraint removed.In the above forms, t1 and t2 may be instruction labels or one of the following special symbols:.+3current address + 3..+2current address + 2..+1current address + 1..the address of the current instruction..-1current address - 1..-2current address - 2..-3current address - 3. fp!q4] Gfp _qBx\Ts!.!ZA!Y; !X2xV !A!U*3!S9!Rh?xP !xO!0!M:!LX4xJ!A!IP)!G0xFH!*!D'$!C+!B% 6!@0!?d=x=!'x<!DE!:>x9 !%%!71!6K=x4!C!3CHI*!1x0;!6 !.HI*!-zx+!=0H2Bit8'H2Bit8R<0R>=0R OddR EvenIOAtten'IOAttenMBMB'IntPendingIntPending'Uses F2Ovf'OvfUses F2BPCChkBPCChk'Uses F2QuadOvfQuadOvf'Uses F2TimeOutTimeOut'Uses F2The complementary form of the branch conditions is provided as a programming convenience. Theeffect of using a complementary branch condition is to interchange the even-odd constraints on thetarget pair.28. NextData and NextInstThe assembler contains a number of macros and placement features to support the NextData andNextInst hardware functions. These functions trap to absolute location 0 in the microstore whenthe quadword buffer containing data from the opcode stream is exhausted; on a trap, the instructionaddress in CIA will be saved in TPC iff the instruction containing NextData/NextInst has a Callencoded in its JC field.The system microcode deals with this situation as follows: First, the trap instruction at 0 contains a"LoadPageExternal[0], GoToExternal[377]" where the GoTo sends control to location 377 on the pagecontaining the NextData/NextInst that trapped. Next, the instruction at 377 on that page will contain a"PFetch4[PC,IBuf,4], GoToP[BufferRefill]" or whatever, where BufferRefill is on page 0. There are restrictionson what can be done by the trap instruction at location 0 (see hardware manual).For this reason it is usually necessary to encode a Call in JC to ensure that the trap subroutine willrestart at the correct place. However, this will usually be a "fake call" (equivalent to CallX) becausethere is no intention to return from a subroutine to .+1 in the instruction stream. Consequently,the assembler has a bit in its output data format (the OddCall bit) which tells MicroD that, eventhough the current instruction contains a call, it is not necessary to place the next instruction inlineat .+1 in the microstore. Some of the macros discussed below set this bit to avoid imposing anunnecessary placement constraint on the program. fp!q4] Gfp _q.x\Tu xYsxXxVgxTxSxQqxOxN#xL{  #xJ#xI-#xG#xE# BqE @[ > :r 6q7% 4-3 2=& 12X /hy,s[ y+E(9y)^ y(Ty'#P #q*< " <, ?&< t T h  R 0& =O=Dolphin MicroAssemblerEdward R. Fiala9 October 198133The macros defined for these two functions are as follows:A_NextInst[RAddr]Instruction dispatch on the next opcode in the opcode stream;PCF[RAddr] addressing selects the word in the quadword-bufferbeginning at RAddr containing the next byte; the NextInst F1 functioncauses the cycler-masker to select the byte in that word according to thelow bit of PCF; forces a fake Call to be encoded in JC. No branchclause is necessary if the successor is the next instruction inline, but ifany branch clause is specified, it must be a (fake) Call or CallX.A_CNextInst[RAddr]Like NextInst, but the JC field is not constrained and any branch clausemay be used. However, unless either a buffer refill trap is impossible(because the BPCChk branch condition is false or because PCF is knownto be odd) or the return address in TPC has already been setup to copewith a trap, you will have to write an explicit Call into the instruction toensure that a buffer refill trap will return to reexecute this instruction;this will be a real call.A_NextData[RAddr]Like NextInst but uses the NextData function rather than the NextInstfunction to obtain the next byte in the opcode stream.A_CNextData[RAddr]Like CNextInst but uses the NextData function.SkipDataUses the NextData function to skip the next byte in the opcode streamwithout referencing it; forces a fake Call to be encoded in JC; does notimpose PCF addressing, so any RM address can be referenced (butbecause the NextData function will use the cycler-masker to select eitherthe left or right byte of the selected RM address, your use of that RMaddress is limited).CSkipDataLike SkipData, but does not impose any constraint on JC; any branchclause may be used. If the branch clause is a Call, it will be "real" andthe successor will be the next instruction inline; if not a Call, you mustbe sure that either a trap is impossible or the return address already inTPC is an appropriate return from the trap subroutine.Here are some examples using these macros:LU _ NextInst[IBuf];*Successor to NextInst is .+1Push:Stack&+1 _ T, NIRet;LU _ NextInst[IBuf], Call[Push];*Successor to NextInst is at the label "Push"T _ CNextData[IBuf], Call[FixPointer];*Real call with NextData functionT _ (Stack&-1) + T, GoTo[Push];Call[FixT];*Call unnessary because return for possible trapT _ CNextData[IBuf], Skip[IntPending];*already setupLU _ Cycle&PCXF, FreezeResult, Skip[R Even]; CSkipData, DblGoTo[A,B,ALU<0];*Trap impossible because PCF is oddDblGoTo[A,B,ALU<0];Note: It is not strictly necessary for NIRet to occur in the instruction immediately after theNextInst/CNextInst. From the hardware manual, it appears that a subroutine which returned bydoing a NIRet could intervene. In other words, the NextInst could be followed by an arbitrarycode sequence; when NIRet occurred, the dispatch address for the next opcode would be put intoTPC; and the Return or NIRet after that would send control to the next opcode. fp!q4] Gfp _q:x\Ts!%=!Z2=!Y0!X2&#!V3!Up1!TBxRh!&"!Q9 !O-!NF !J#xH|!/!G6xEt!.xC!>!Bl5!A 5!?"'!>J0!<x;A!,!9F!89!76!56 2pq*/s, x.M,,  )&,(&O ,!$&,",!Y, pqV I (6 JY N 8=RcDolphin MicroAssemblerEdward R. Fiala9 October 19813429. Placement DeclarationsCurrently, you must specify the page on which each instruction is placed. This is done by adeclaration of the form:OnPage[n];where the integer n is the page number (0 to 17). Subsequently assembled instructions will beplaced on the specified page. The OnPage declaration may appear only as a separate statement.Two other declarations may appear only as clauses in an instruction being assembled; these specifythe exact placement of the instruction and also do OnPage, so that subsequently assembledinstructions will be placed on the same page. These are:At[n1]places the current instruction at location n1.At[n1, n2]places the current instruction at location n1+n2.Opcode[n]places the current instruction at 2001+(4*n), where n is the opcode (0 to 377)DispTable[Length,Mask,Value] appearing in an instruction statement causes that instruction to begina group of Length consecutively-placed statements, where 1 <= Length <= 20. The firstinstruction will be placed at a location such that And[location,Mask] = Value, where Mask defaultsto 17 and Value to 0. It is required that Length+Value be less than 21. Placement of theinstruction containing DispTable will be further constrained by whatever OnPage declaration is inforce.Note that DispTable will not handle all dispatch tables; it requires that a table be no longer than 20with no "holes" and that the instructions in the table appear as consecutive statements in the sourceprogram. Whenever these conditions cannot be met, At clauses must be used for the instructions inthe table.Opcode declarations are required for the entry instructions of opcodes; At declarations are requiredfor trap instructions, for instructions in dispatch tables that cannot use DispTable for some reason,and in a few other situations, but MicroD will take care of normal placement constraintsautomatically.To assist in defining absolute locations for dispatch tables and manually placed instructions the"LOCA" macro is defined:Loca[Name,Page,Offset]defines Name as an integer equal to Page*400 + Offset, where Page and Offset areintegers.In addition to the above placement declarations, there are two macros for "reserving" or"unreserving" locations in IM. These macros, which direct MicroD to avoid placing instructions inparticular microstore locations, are as follows:IMReserve[p,w,n]where p, w, and n are integers reserves n locations beginning at word w on page p. fp!q4] Gfp ^r []q2* YyVs Sq2, Q^ NFC L{O J9xGs.xFH +xDF ARq,7 ?O =N ;A :'H 8] 4I 3 ^ 1U_ / ,$@ *N:+ (R & #G U !}xs>Z  q0( AR v0xsE  =Ty Dolphin MicroAssemblerEdward R. Fiala9 October 198135IMUnReserve[p,w,n]unreserves n locations beginning at word w on page p.For diagnostics, the declaration statement "MidasInit;" may be issued to reserve the severallocations on page 0 and all of page 17 for use by the debugger Midas.30. Tasking ConsiderationsSince task switching occurs only when an "unrestricted" return is executed, each task must be sureto execute instructions containing returns often enough to satisfy the timing requirements of taskswhich are higher (or sometimes lower) in priority. Here "unrestricted" means that the instructionpreceding return did not do APCTask&APC_ or UseCTask, which disallow task switching.When an unrestricted return is executed, the highest priority different task requesting service willrun, or the emulator if no other tasks are requesting. This has several implications:First, when a high priority task such as the display driver executes a return when it has not yetblocked, it will lose control to some other task (usually the emulator) until that task does a return.This means that it should not do too many returns else the accumulated interference of lowerpriority tasks will add up to so large a value that its timing requirements are not satisfied.Secondly, each task must be sure to execute Returns frequently enough that higher priority tasksreceive adequate service.We can illustrate this with an example. Suppose that the timing requirement of the display driver isthat upon issuing a wakeup request it be granted 88 cycles out of the next 288 cycles and that itexecutes one intermediate return before its final return after blocking. Initial service will be delayeduntil whatever task is running executes a return, and further delayed until all higher priority tasksare satisfied. At the intermediate return, a lower (or higher task) will run first and then higher tasksuntil they are satisfied. If page or write protect faults or single-error logging are possible, thensome allowance must be made for the fault task, which has a long burst of non-tasking computationat the beginning of each fault. The total interference of all these other tasks must be less than 200cycles.The emulator task for the current AMesa system microcode attempts to satisfy this requirement bytasking at least once every 46 cycles.Another programming consideration is the exact placement of returns. It is frequently possible tochoose one of several places; one good place is immediately before an instruction that will beaborted--e.g., before an instruction that will read an RM word for which a PFetch has just beenstarted or write an RM word for which a PStore has just been started. An undesirable placement iswhere the current task could proceed because it is not issuing memory references but where anothertask might experience an abort because MC1 is busy. fp!q4] Gfpx_9s5 [q\ Z E U*r QqU OB! N#R LXT H>pq GV CM A9- @:" >JO :@ 9  550 3%< 2'B 0;e .qM ,"C *B )G 'F #8( " & V E .1 8'; m>$ 3 4 \>RDolphin MicroAssemblerEdward R. Fiala9 October 19813631. Microcode OverlaysThe barest minimum provisions are made for microcode overlays. When assembling basic systemmicrocode, the IMReserve macro discussed in the "Placement Declarations" section may be used todisallow the use of any set of IM locations by MicroD. Also, any pages totally unused by thesystem microcode or containing throwaway initialization code are available to overlays. Finally,particular instructions in the system overwritten by particular instructions in an overlay must bemanually placed with "At" declarations in both the system microcode and the overlay.An overlay must use IMReserve to prevent its use of any locations on pages that it shares withsystem microcode. MicroD has a switch that will write a xxOccupied.Mc file containing IMReservestatements.Any instructions in the system branched to from an overlay must be manually placed with "At" andvice versa. Then, instead of using LoadPage[n] and GoTo[n] or Call[n], you must useLoadPageExternal[n] and GoToExternal[n] or CallExternal[n] in instructions that branch between thesystem and an overlay.32. Recent Hardware and Assembler Changes1.SUB, EQUATE, ASMMODE, TRACEMODE, and WHILE Micro builtins and the "warning"code for the ER builtin.2.Some names have been assigned to R-bus sources that were formerly referred to byGetRSpec[n] phrases (e.g., Cycle&PCXF, SStkP&NStkP, CTask&NCIA, Page&Par&Boot,ALUResult&NSALUF).3.Bugs in use of GoTo with read/write control store were fixed.4.Some error messages for PFetch2/PStore2 and PFetch4/PStore4 were changed to warnings, andthe OddOK and NonQuadOK clauses to the right were added to overrule the warnings.5.The specification of a second RM address with Input[..], Output[..], and ReadPipe[..].6.OddBaseOK was removed and OddPFetch1, etc. were recently added.7.SkipData, CSkipData, CNextInst, Loca, IMData, HiA, LoA, RV2, RV4, CallX, negativeconstants, Formn, Form-n, and Nib0RSh8, andIF, UNLESS, ELSEIF, ELSE, ENDIF conditionalassembly stuff are recent assembler additions.8. The IMMASK memory handled by MicroD and the DispTable macro which outputs placementconstraints for dispatch tables are new.9. Additional MicroD output files. fp!q4] Gfp ^r []q R YA W6' Ua T3R RhT NK M,C Ka GP F$&>' DZ^ B =r* :'q2A 8] 42&* 3 &( 1U -2= *r2B (Q %52V !2? Q2 H  +){ . J8 (  # =VE HELVETICA TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN  TIMESROMAN TIMESROMAN  TIMESROMAN "*17>:BJ%OU\bgiq%w~  B " " ic"B":J%39Z)Y &Z ")&i%9i#B"  No default fontiX":C:#:; Nd"B"P:C!T:C!Q:C":C!L:C%:C":CP:C%:C!:C #j/%2D0Microassembler.PressFiala 9-Oct-81 16:15:23 PDT