Communication Between BASIC and Assembly Language
127
Using Common
Another way to pass information between BASIC and assembly language routines is through
BASIC's common area.
You may recall from subprograms in BASIC that if you have a COM statement in the main
program, the locations named therein can be accessed by other BASIC subprograms and
functions through their own COM statements. Though the subprograms may change the
names, the locations are the same. The order of appearance in a COM statement is all-
important. If a main program has the statement -
and a subprogram has the statement -
then X and A are the same storage location, Band Yare the same, and C and Z are the same.
The same kind of operation is available in your assembly language routines with the COM
pseudo-instruction -
As with the SUB pseudo-instruction, the COM only serves as a preface. It is followed by one or
more parameter declarations of the same types as in the SUB -
'T
1-••
.. i ..
i'·! :
F~~~
E: : : I . . . .
The FIL is not permitted, since there is no corresponding item within BASIC's COM syntax.
Each pseudo-instruction used after an assembly language COM corresponds to an item in the
COM declaration in the main BASIC program. Just as in a BASIC subprogram, the types must
agree.
1
However, the ANY pseudo-instruction fulfills the same function here as it does with the
SUB pseudo-instruction - to allow any type of item to be passed.
III the types do not correspond, an error results (number 198).