................................< .laser .topmargin 1" .margin 1" .; The following rulers work for Times-Roman and Helvetica - 10 point type .font times .point 10 .; Three columns per page (2 1/16") .; ................................< .; Two columns per page (3 1/16") ..................................................< .; One column per page (6 5/8") .; ........................................................................................................< .hlt bold Alphanso's Assembler Assylum by SDH _Generating a UNIVERSAL file for Your MACROs_ Hey gang! How are you and your MACROs these days? This month let's learn how to generate our own personal UNIVERSAL file filled with our own MACRO definitions. Once we have created the MACROs we need and place them in our special universal file, each time we write a new assembly language program we can "assume" that our MACROs are part of the entire library and use them without ever defining them within the source code! Slick! If you have missed the last two sessions of the Assylum, be sure to catch up on your reading. Talk about getting fancy! _Why a Universal File?_ Why would one ever want to create a univeral file in the first place? A couple of good answers to this question. One reason is that it will save you a good deal of time: you only have to define your favorite MACROs once. Second reason: program compactness. If you begin to create more and more custom MACROs, you could have page upon page of definitions before you even begin the main body of your program. Third reason: program readability. If you properly name your MACROs and provide solid comments within the main body of your code, the final product will be much more readable. Fourth reason: speed. Rather than copying in all your MACRO definitions, you will be able to SEARCH for these definitions at assembly time - much faster. Finally, it's cool... very cool. All assembly language programmers like to "be cool". _How to Construct a Universal file_ Next step, since we all decided that cool is "in", is to create a UNIVERSAL file. You will find that a universal source code file looks very similar to our previous files. The simple rules to follow are listed below. Rule 1: you cannot use any SEARCH lines from within a .UNV source file. Rule 2: you cannot use the COPY command either (we haven't discussed this, but COPY will basically "yank" in a piece of .M68 code upon assembling). Rule 3: a .UNV source code file may only contain MACRO definitions and SYMBOL definitions - NO CODE may be generated. Not as spooky as you think. If you are real interested in looking at a .UNV file, LOG to the MAC: account, DSK0:[7,7], and VUE (or TYPE) SYS.M68 or TRM.M68. Most of the information in these two files consist of SYMBOL definitions, but TRM.M68 has at least one MACRO within the file towards the bottom. Both SYS.M68 and TRM.M68 when assembled create SYS.UNV and TRM.UNV - two files we have SEARCHed over and over. .bl | .hlt key Now that the rules are clear, the rest is a snap. Let's once again use the file JOBRUN.M68 as our example. VUE JOBRUN.M68 from last months session (or get JOBRUN.M68 off the Network, PPN [100,51]). Unyank the MACRO portion of the file. You can do this by following these steps: placing the cursor at the first DEFINE statement and hit a _|cP|_. Now move the cursor to the last ENDM statement of the MACRO definitions and hit another _|cP|_. You have just "marked" a block of text. Now hit a _|RETURN|_ to move the cursor out of the "dim" block you just marked. Hit and _|ESC|_ to get to VUE command mode (the ">") and type U MYMACS (for "unyank MYMACS"). This will create a file called MYMACS.M68. The cursor will be resting at the ">" at this point. Now type DELETE. This will delete the block you marked from within JOBRUN. We still are not done. Again hit an _|ESC|_ to return to the text of JOBRUN. Notice that the MACROs have been removed from this file. In order for the assembler to "find" our MACRO definitions, we need to add in another SEARCH instruction (just below SEARCH TRM). This SEARCH line should read SEARCH MYMACS. What this instruction line will do is inform the assembler to SEARCH a file called MYMACS.UNV (notice the .UNV extension). All a SEARCH does is locate any MACRO or SYMBOL definitions within a given .UNV file for processing. If you never use any of the MACROs within MYMACS.UNV but still included the SEARCH instruction, no errors would occur and it would be "legal beagle". If you do use a MACRO or a SYMBOL from MYMACS, then the SEARCH statement would provide the proper definition. Simple! Finally, we need to create the .UNV file from MYMACS.M68. Before you assemble JOBRUN, Finish from VUE and now VUE MYMACS.M68. At the top of the file, we need to inform the assembler that this .M68 file will generate a .UNV file. We do this by placing at the top of the file the following one line opcode: UNIVERSAL (see enclosed code below). Now assemble MYMACS.M68. Notice that the assembler only goes through two phases of assembly, and it also informs you that the Universal file is finished. Bingo - instant library! .font courier .hlt bold .point 10 _UNIVERSAL_ _ DEFINE TYPEIT V,B_ _;+---_ _;| TYPEIT will process a JCB variable that is two words packed RAD50 data_ _;| and type this variable to the screen in ascii format._ _;| where_ _;| V = variable to be UNPACKED_ _;| B = buffer area to place unpacked characters_ _;+---------------------------------------------------------------------------_ _ LEA A1,V(A4) ;A1 points to variable to be unpacked_ _ LEA A2,B(A5) ;and ^ A2 to byte "0" of "BUFFER"_ _ UNPACK ;get the letters unpacked_ _ UNPACK ; ...for up to full letters_ _ CLRB @A2 ;Place a "null" after the characters_ _ LEA A2,B(A5) ;Repoint A2 to byte "0" of "BUFFER"_ _ TTYL @A2 ;Print out all chars until a null_ _ENDM_ _DEFINE PRTTAB AA,BB_ _;+---_ _;| PRTTAB acts just like "PRINT TAB (#,#) from within BASIC_ _;| where_ _;| AA is the first #, BB is the second #_ _;+------------------------------------------------------------_ _ MOVB #AA,D1 ;move 1st number into D1_ _ LSLW D1,#10 ;shift it left 8. bits_ _ MOVB #BB,D1 ;move in 2nd number_ _ TCRT ;and perform TCRT call_ _ENDM_ _DEFINE TABDWN AA,BB_ _;+---_ _;| TABDWN - or "TAB DOWN" will place the cursor at the row specified by_ _;| AA and the column specified by BB. Assumes a data register_ _;| (AA) has been "dedicated" to keep track of which row._ _;| where_ _;| AA is a dedicated data register holding current row number_ _;| BB is the column number_ _;+----------------------------------------------------------------------_ _ MOVB AA,D1 ;move in value from dedicated reg._ _ LSLW D1,#10 ;shift it left 8. bits_ _ MOVB #BB,D1 ;move in column number_ _ TCRT ;and perform TCRT call_ _ INC AA ;increment dedicated data register_ _ENDM_ .font times .point 10 Now we are ready to assemble JOBRUN. Type M68 JOBRUN and watch how the assembler will SEARCH MYMACS at the appropriate time and generate JOBRUN.LIT with the exact same hash code total as before. Wasn't that easy??? Now for some questions and answers. First, where should you place MYMACS.UNV? Probably the best location is in the MAC: account, DSK0:[7,7]. That way, no matter what PPN you are currently in, if you have a SEARCH MYMACS instruction line in a file you are creating, the assembler will find this file. Next question: how come the assembler found MYMACS during this session when I didn't move MYMACS down to DSK0:[7,7]? The answer, as you have probably already guessed, is that the assembler will look in the PPN you are currently working in if it cannot find the .UNV file in the MAC: account. What if I want to add more of my favorite MACROs to MYMACS? Well, if you leave MYMACS.M68 in the MAC: account, each time you generate a new MACRO that you think you will use over and over, simply VUE MYMACS.M68, add in the new definition, re-assemble, and your done! I noticed that MYMACS does not contain an END statement, how come? The answer to this one is also slick: with no END statement included, if there ever comes a time that you would rather COPY MYMACS.M68 to a file, you may do so. If there was an END statement contained within MYMACS, as soon as you copied in the file, you would be at the "END" of your code! .hlt bold _Wrapping Up_ Perform the step above to be sure you understand how to create a universal file. As the series continues, we will begin to employ more and more of the neat features of the Alpha Micro assembler, so don't find yourself getting behind! Coming up in the future will be number conversion routines, block programming using the LNKLIT command, and even file I/O! Also, as long as I keep getting positive comments about this series I will continue submitting the AAA. Input and suggestions are more than welcome. I enjoy writing these article as long as somebody gets something out of them. See you next month. Bye!