"IBM personal computer assembly language tutorial" - читать интересную книгу автора (Auerbach J.)

every assembly. When you are assembling a subroutine, you just say

END

but when you are assembling the main routine of a program you say

END label

where 'label' is the place where execution is to begin.

Another pseudo-op illustrated in the program is ASSUME. ASSUME is like the
USING statement in 370 assembler. However, ASSUME can ONLY refer to seg-
ment registers. The assembler uses ASSUME information to decide whether to
assemble segment override prefixes and to check that the data you are try-
ing to access is really accessible. In this case, we can reassure the
assembler that both the CS and DS registers will address the section called
HELLO at execution time. Actually, the SS and ES registers will too, but
the assembler never needs to make use of this information.

I guess I have explained everything in the program except that ORG
pseudo-op. ORG means the same thing as it does in many assembly languages.
It tells the assembler to move its location counter to some particular
address. In this case, we have asked the assembler to start assembling
code hex 100 bytes from the start of the section called HELLO instead of at
the very beginning. This simply reflects the way COM programs are loaded.
When a COM program is loaded by the system, the system sets up all four
segment registers to address the same 64K of storage. The first 100 hex
bytes of that storage contains what is called the program prefix; this area
is described in appendix E of the DOS manual. Your COM program physically
begins after this. Execution begins with the first physical byte of your
program; that is why the JMP instruction is there.

Wait a minute, you say, why the JMP instruction at all? Why not put the
data at the end? Well, in a simple program like this I probably could have
gotten away with that. However, I have the habit of putting data first and
would encourage you to do the same because of the way the assembler has of
assembling different instructions depending on the nature of the operand.


IBM PC Assembly Language Tutorial 19


Unfortunately, sometimes the different choices of instruction which can
assemble from a single opcode have different lengths. If the assembler has
already seen the data when it gets to the instructions it has a good chance
of reserving the right number of bytes on the first pass. If the data is
at the end, the assembler may not have enough information on the first pass
to reserve the right number of bytes for the instruction. Sometimes the
assembler will complain about this, something like "Forward reference is
illegal" but at other times, it will make some default assumption. On the