Option
/PACKC[[ODE]][[:number]]
The /PACKC option turns on code-segment packing. The linker packs code segments by grouping 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.
The number specifies the maximum size of groups formed by /PACKC. The linker stops adding segments to a group when it cannot add another segment without exceeding number; then it starts a new group. The default segment size without /PACKC (or when /PACKC is specified without number) is 65,500 bytes (64K – 36 bytes).
The /PACKC option produces slightly faster and more compact code. It affects only programs with multiple code segments. This option is off by default and, if specified in an environment variable, can be overridden with the /NOPACKC option.
Code-segment packing provides more opportunities for far-call optimization (which is enabled with the /FARCALL option). The /FARCALL and /PACKC options together produce faster and more compact code. However, this combination is not recommended for Windows applications.
Summary: Use caution when packing assembly-language programs.
Object code created by Microsoft compilers can safely be linked with the /PACKC option. This option is unsafe only 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 code produces incorrect results when used with /PACKC, because /PACKC causes the two segments to share the same segment address. Therefore, the procedure would always return 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