Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
/PACKC Option
◄Up► ◄Contents► ◄Index► ◄Back►
─────/PACKC Option──────────────────────────────────────────────────────────
Syntax: /PACKC[ODE][:number]
The /PACKC option turns on code-segment packing.
LINK packs code segments by grouping together neighboring code
segments that have the same attributes. Segments in the same group
are assigned the same segment address; offset addresses are
adjusted accordingly. All items have the same physical address
whether or not the /PACKC option is used. However, /PACKC changes
the segment and offset addresses so that all items in a group
share the same segment.
Specify <number> to set the maximum size of groups formed by
/PACKC. The default without <number> or /PACKC is 64K - 36. When
LINK cannot add another segment without exceeding <number>, it
forms a new group.
See: ◄Entering Numeric Arguments►
/PACKC produces slightly faster and more compact code. It affects
only programs with multiple code segments.
Code-segment packing provides more opportunities for far-call
optimization (enabled with the /FARCALL option). /PACKC and
/FARCALL together produce faster and more compact code. However,
this combination is not recommended for Windows applications.
See: ◄/FARCALL Option►
Code-segment packing is off by default. However, if an environment
variable (such as LINK or FL) includes /PACKC, you can use the
/NOPACKC option to override /PACKC. /NOPACKC overrides /PACKC if
/PACKC is specified first.
See: ◄LINK Environment Variable►
◄/NOPACKC Option►
Caution
/PACKC can be unsafe when used with assembly-language programs
that make assumptions about the relative order of code segments.
For example, the following assembly code attempts to calculate the
distance between CSEG1 and CSEG2. This produces incorrect results
when used with /PACKC, because /PACKC causes the two segments to
share the same segment address. The procedure always returns zero.
CSEG1 SEGMENT PUBLIC 'CODE'
.
.
.
CSEG1 ENDS
CSEG2 SEGMENT PARA PUBLIC 'CODE'
ASSUME cs:CSEG2
; Return the length of CSEG1 in AX.
codesize PROC NEAR
mov ax, CSEG2 ; Load para address of CSEG1
sub ax, CSEG1 ; Load para address of CSEG2
mov cx, 4 ; Load count
shl ax, cl ; convert distance from paragraphs
; to bytes
codesize ENDP
CSEG2 ENDS
-♦-