Program organization. SegmentsThe program segment is described by the directives SEGMENT and ENDS.
segment_name segment readonly alignment type width 'class' ...
segment_name ends
Segment name — a label which will be used for receiving the segment address,
and also for a combination of segments in groups.
All five operands of the directive SEGMENT are optional.
READONLY. If this operand is present, MASM will give out an error message on
all commands which are carrying out record in this segment. Other assemblers
ignore this operand.
Alignment. Specifies to the assembler and the linker, the segment can begin
with what address. Values of this operand:
BYTE — from any address;
WORD — from the even address;
DWORD — from the address, multiple of 4;
PARA — from the address, multiple of 16 (limit of the paragraph);
PAGE — from the address, multiple of 256.
Alignment on limit of the paragraph is by default used.
Type. Chooses one of possible types of a combination of segments:
the PUBLIC type (MEMORY synonym is sometimes used) means that all such
segments with an identical name, but different classes will be united in one;
the STACK type — the same, as PUBLIC, but has to be used for stack
segments because when loading program the segment received by association
of all segments like STACK, will be used as a stack;
segments like COMMON also unite with an identical name in one, but isn't
consecutive, and to the same address, therefore, length of a total segment will be
equal not to the sum of lengths of united segments, as in case of PUBLIC and
STACK, but length of the maximum. In such a way sometimes it is possible to
form overlay programs;
the AT type — expression specifies that the segment has to locate at the fixed
absolute address in memory. The result of the expression which is using as an
operand for AT, is equal to this address divided on 16. For example: segment
at 40h — a segment beginning to the absolute address 0400h. Such segments
usually contain only the labels indicating memory areas which can be demanded
to the program;
PRIVATE (value by default) — a segment of this kind doesn't unite with other
segments.
Width. This operand can accept USE16 and USE32 values. The size of the
segment described as by USE16, can't exceed 64 KB, both all commands and
addresses in this segment are considered as the 16-bit. In these segments it is
all the same possible to apply the commands using 32-bit registers or referring to
data in 32-bit segments, but they will use a prefix of width change of an operand
or the address and will appear more long and more slowly. Segments of USE32
can occupy to 4 Gb, both all commands and addresses in them by default the 32-
bit. If width of a segment isn't specified, USE16 is by default used if before the
directive .MODEL there wasn't apply the directive of setting an admissible set of
commands .386 or higher.
Segment class — is any label taken in unary quotes. All segments with an
identical class, even segments like PRIVATE, will be located in the executed file
directly one after another.
group_name group
segment_name...
assume register:link...
Date: 2015-01-29; view: 1282
|