119 lines
5.3 KiB
Plaintext
119 lines
5.3 KiB
Plaintext
CHAPTER 2 A86 DEMONSTRATION
|
|
|
|
|
|
To give you a feeling for the operation of A86, I have provided
|
|
some source files for you to assemble. You should make sure your
|
|
current directory (or a PATH directory) is the one that contains
|
|
this assembler package, and perform the following operations to
|
|
see the assembler package in action:
|
|
|
|
|
|
Assembling a Very Short Program: PAGE.COM
|
|
|
|
First, let's assemble a very short program; a program that sends
|
|
an ASCII form feed (hex 0C) to your line printer. The source for
|
|
this program is PAGE.8; type the command TYPE PAGE.8 to see how
|
|
simple this program is: note the lack of red tape directives
|
|
(NAME, ASSUME, END, PUBLIC, etc.) required by other assemblers.
|
|
Now type the command A86 PAGE.8 to assemble the file. If you are
|
|
working on a hard disk, make sure you don't blink your eyes after
|
|
typing the command; you'll miss the assembly, because A86 is
|
|
FAST, FAST, FAST.
|
|
|
|
You now have a file PAGE.COM, which is an executable program. If
|
|
you now type the command PAGE with your printer turned on, and if
|
|
your printer recognizes the form feed character, then it should
|
|
advance to the next page. You have just created a useful tool.
|
|
By altering the DB line in the source code that contains the form
|
|
feed, you can create tools to output other control sequences to
|
|
your printer.
|
|
|
|
|
|
Demonstration of Error Reporting
|
|
|
|
Now type the command ERDEMO, invoking the batch file ERDEMO.BAT.
|
|
This will invoke an assembly of a source file PAGE.BAD (copied
|
|
from PAGE.BL so you can run this demo again), into which I have
|
|
deliberately placed an erroneous statement, XCHG BL,AX. Note
|
|
that A86 tells you that it has inserted error messages into
|
|
PAGE.BAD, and saved the original source in PAGE.OLD.
|
|
|
|
Now use your favorite text editor to edit PAGE.BAD. You can use
|
|
your editor's string search function to find a tilde symbol,
|
|
which brackets all A86 error messages. Without altering the
|
|
messages, change the BL to BX, and exit your editor. Now type
|
|
the command A86 PAGE.BAD to reassemble the file. You should get
|
|
a successful assembly. Now type the command TYPE PAGE.BAD, and
|
|
note that A86 has removed the error messages for you. Wasn't
|
|
that easy?
|
|
|
|
|
|
Assembling a Longer Program with Library Files: REV.COM
|
|
|
|
Let's see A86 assemble a program with four source files. Type the
|
|
command A86 REV.8 to the console. A86 will assemble the REV.8
|
|
file you specified, see that there are undefined symbols in the
|
|
program, then assemble the files LINES.8, MSDOS.8, and USAGE.8,
|
|
listed in the library file A86.LIB, which I created using the
|
|
tool A86LIB available only to registered users.
|
|
2-2
|
|
|
|
REV is a tool that exists in the Unix operating system. It is a
|
|
"filter"; that is, it reads from standard input, transforms the
|
|
input, and outputs the transformed data to standard output. The
|
|
transformation that REV performs is to reverse all lines, so that
|
|
they come out backwards.
|
|
|
|
The usefulness of REV is in conjunction with other tools. In
|
|
particular, suppose you have a list of words that you wanted
|
|
sorted according to their last letters, not their first. You run
|
|
the list through REV, to get the words spelled backwards. Then
|
|
you run that output through SORT, to sort them that way. Finally,
|
|
you run the output of SORT through REV again, to get the words
|
|
spelled forwards again, but still sorted according to their
|
|
backwards spellings.
|
|
|
|
The normal usage of REV is, therefore, in conjunction with
|
|
redirection of standard input and output; e.g. REV <infile
|
|
>outfile. If you want to just see if REV works, type REV, the
|
|
enter key, your first name, the enter key, your last name, the
|
|
enter key, the F6 key, and the enter key. You'll get your first
|
|
and last name spelled backwards.
|
|
|
|
|
|
Using XREF on a medium-sized program: TCOLS.COM
|
|
|
|
Type the command MTCOLS to execute the batch file MTCOLS.BAT.
|
|
Observe that the file assembles the file TCOLS.8 into the program
|
|
TCOLS.COM. Then the batch file runs the XREF program, to produce
|
|
a cross reference listing TCOLS.XRF of the program.
|
|
|
|
Type the command TCOLS. The TCOLS program you just assembled
|
|
will execute, and notice that you have given it no parameters. It
|
|
thus gives you a self-documenting message. Note that towards the
|
|
end of the message is an example showing how TCOLS can be used to
|
|
print XREF listings. You can do so now by turning your printer
|
|
on and typing an appropriate command; e.g., TCOLS <TCOLS.XRF 4 6
|
|
80 66 >PRN for 4 columns, skip 6 lines between pages, which are
|
|
80 columns by 66 lines.
|
|
|
|
|
|
Using EXMAC
|
|
|
|
Type the command MEXP, invoking the batch file MEXP.BAT, which
|
|
executes the command EXMAC TCOLS <TCOLS.8 >TCOLS.EXP to create a
|
|
version of TCOLS with macros expanded. Look at the file
|
|
TCOLS.EXP, and note that the DEFAULT macro defined there has had
|
|
all of its calls expanded. Type the command A86 TCOLS.EXP and
|
|
note that it assembles into TCOLS.COM just as the original file
|
|
does.
|
|
|
|
Type the command EXMAC TCOLS to enter interactive mode. The
|
|
program pauses, waiting for you to type in lines. Type a garbage
|
|
line, e.g. "abc", and see the line echoed back to you. Now type
|
|
the macro call: DEFAULT FOO,7 and see the macro expanded
|
|
interactively. Type Control-Z followed by the enter key to exit
|
|
the EXMAC program. (On most IBM-compatible computers you can
|
|
type F6 to get a control-Z.)
|
|
|
|
|