10. Using SMAL32
On UNIX systems, SMAL32 is invoked by typing the command
smal32 [ -L ][ -D ][ -P <number> ][ -U <directory> ] <filename>
Where <filename> is the name of the assembly language file to be processed. Typically, <filename> will end with the suffix .a indicating that it is an assembly language file. If no other versions of SMAL are in use, the name "smal" is frequently defined as an alias for "smal32"; this alias may also specify defaults for one or more of the command-line options.
The loadable or linkable object code resulting from the assembly will be produced on files with names based on <filename>, with any suffix removed, and with the suffix .o (for object) appended.
The assembly listing will be produced on files with names based on <filename>, with any suffix removed, and with the suffix .l (for listing) appended.
The -L command-line option suppresses generation of a listing. This will generally be used when the SMAL assembler is used as a linker, since the listing produced by linkage is generally near-useless.
The -D command-line option causes SMAL to dump the contents of the symbol table at the end of the assembly process. The dump, if produced, will be on a file named with a .d siffix and the same prefix as was used for the object and listing files.
The -P command-line option sets the number of lines per page in SMAL listings. This defaults to 60 and must be larger than 5 to allow room for page titles and subtitles.
The -U command-line option sets the name of the directory to search for files to be included by the USE assembler directive. By default, no search will be made.
When SMAL32 is run, any errors that preclude assembly, such as improperly formed command line arguments, will cause SMAL to exit and output a diagnostic message prior to attemtpting to open or create any files. Any assembly errors will be noted in the listing and also noted with diagnostic messages. The note of assembly errors included in the listing contains the same diagnostic message, augmented by underlining the offending parts of the input line.
Each line of a SMAL listing file contains 4 fields; these are, from left to right, the location counter, the generated object code, the source line number and the assembly language source file. Here is a fragment of a typical listing:
+000082: 01 02 03 84 B 1,#2,1+(5-3) +000085: 00000001 85 W 1,#2,1+(5-3) 00000002 00000003 +000091: 41 27 22 5A 86 ASCII "A'",'"Z' +000095: 41 27 22 5A 87 ASCII "A'",('"'),('X'+2)
The location counter at the start of this fragment was relocatable 8216. The leading plus in front of any value in the first two fields indicates that that value is relocatable; that is, that some constant, known to the loader, will be added to it. For the location counter, the value to be added is the relocation base -- the location in memory where the loading of this object file begins. The relocation base is also added to the addresses of other parts of the same relocatable block of code. For external symbols and common blocks, the value to be added is the address of that external symbol or common block.
The location counter value is only given at the start of each line of assembly code and only when that line actually caused object code to be generated; consecutive bytes, halfwords and words will be shown without showing the value of the location counter again, so long as these are loaded consecutively in memory.
The second field above contains the object code generated, listed in hexadecimal, again, with a leading plus used to indicate relocation. In this example, the first line (line 84) generated 3 bytes of absolute object code, while the second line (line 85) generated 3 words of object code. All object code that would not fit on a line is printed on successive lines.
The third field is the source line number, printed in decimal; lines 84 through 87 are included above. The source code is set off from the line number by two spaces.
All error messages resulting from assembling a line of code are listed after that line (and after any generated object code). In addition, the offending parts of the input line are underlined, to the extent that the assembler is able to identify the source of the problem. The listing of a line containing errors is given below:
+0000C0: 00000000 12 W 0, UNFUNC(1)+UNDEF) 00000001 unbalanced parentheses ====== ====== undefined symbol invalid function
Note in this example that the order of the error messages and the order of the errors on the input line is not necessarily the same! Furthermore, the underlining of the undefined identifier UNDEF has run into the underlining of the unbalanced parenthesis, so that it looks like only two errors are underlined.
When attempting to print an assembly listing, it is important to set the printer's font to a monospaced font such as Courier. That particular font is the classic typewriter font that was imitated by many first and second generation computer printers, while the VT100 font, if it is available, imitates the typical fonts found on third-generation display screens and personal printers.
The symbol table dump produced by the SMAL32 -D option consists of the contents of the symbol table, one line per symbol, in almost random order. Standard sort programs can be run on the dump file to sort it in either numerical order by definition or alphabetical order by symbol, depending on the use to be made of it. The definiton file is formatted as legal SMAL code, so inserting a definiton file into another program will sometimes suffice to give the same symbols the same definitons they had in the first program!