/PACKC[[ODE]][[:number]]
The /PACKC option turns on code-segment packing. Code-segment packing is on by default for segmented executable files and for DOS programs created with overlays or with the /TINY option. It is off by default for other DOS programs. You can use the /NOPACKC option to override /PACKC.
The linker packs physical code segments by grouping neighboring logical 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. It then 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.
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