Wed, 13 Nov 2013, 21:01

My students,

Congratulations on now being past the 2nd midterm and onto the home stretch!
It does not get easier, but at least you might be able to soon see the light 
at the end of the tunnel!  :-)

Before the midterm I got the following email.  It wasn't necessary to bog
you down with my answer while you were studying for the midterm, so I decided
to put it on hold until after the exam.

A student writes:

> Hello Professor Patt,
> I hope you're doing well! In preparation for the exam tomorrow, I was
> rereading chapters 1-10 and in chapter 7, it talks about the pseudo-op
> .EXTERNAL. I was wondering if this is something that would be on the exam
> and even if not, I was hoping you could explain it to me. I'm not quite
> sure I understand exactly how to use .EXTERNAL in the character count
> program it uses as an example to describe its use.
> Thank you and have a good day!
> <<name withheld to protect the student who saw .EXTERNAL but not in class>>

The student is right, I shortchanged you on an explanation of .EXTERNAL.
I will correct that right now.

I did tell you in class that the Linker is a software package that combines
separately assembled .obj files into one executable image that can be executed 
at run-time.  Suppose one writes a program that includes


but there is no label FUNCTION in the program.  That is, the programmer
assumes that FUNCTION is a label in another part of the program that is
assembled separately.  That is JSR wants to jump to FUNCTION which is a
label in another module that will be linked into a single executable image
to be executed.  Perfectly reasonable, right!  Of course, but someone has
to know about this and "fix up" these linkages.  They can not be done on
the individual modules because the module with the label FUNCTION does not
know the address of the JSR instruction, and the module containing the JSR
instruction does not know the address corresponding to FUNCTION.

We solve the problem by having the assembler flag FUNCTION in the symbol
table in both modules as something that needs to be resolved by the Linker,
that is, when the modules are all combined into one executable image.  The
linker looks in the symbol tables of each module, and uses information there
to resolve those addresses.  The relevant entries are flagged with a name.
.EXTERNAL and .GLOBAL are two names that can be used for this purpose.


Enjoy the weekend.  See you in class on Monday.

Yale Patt