Defines an uninitialized block of storage called a common block, which can be common to more than one module.
.comm | Qualname, Expression[, Number] |
where QualName = Name[[StorageMappingClass]]
Note: Name is required. StorageMappingClass is optional and enclosed within brackets if specified. RW is the assumed default ifStorageMappingClass is omitted.
The .comm pseudo-op defines a block of storage specified by the Qualname parameter. The the block size is specified in bytes by the Expression parameter.
Note: By convention, use of the TD storage mapping class is restricted to common blocks no more than four (4) bytes long.
The valid values for StorageMappingClass are RW, TD, UC, and BS. These values are explained in the article on the .csect pseudo-op. If any other value is used for StorageMappingClass, the default value RW is used and a warning message is reported if the -w flag is in effect.
If TD is used for the storage mapping class, a block of zeroes, the length specified by the Expression parameter, will be written into the TOC area as an initialized csect in the .data section. If RW, UC, or BS is used as the storage mapping class, the block is not initialized in the current module and has symbol type CM (Common). At load time, the space for CM control sections with RW, UC, or BC storage mapping classes is created in the .bss section at the end of the .data section.
Several modules can share the same common block. If any of those modules have an external Control Section (csect) with the same name and the csect with the same name has a storage mapping class other than BS or UC, then the common block is initialized and becomes that other Control Section. If the common block has TD as its storage mapping class, the csect will be in the TOC area. This is accomplished at bind time.
If more than one uninitialized common block with the same Qualname is found at bind time, space is reserved for the largest one.
A common block can be aligned by using the Number parameter, which is specified as the log base 2 of the alignment desired.
.comm proc,5120 # proc is an uninitialized common block of # storage 5120 bytes long which is # globally visible. # Assembler SourceFile A contains: .comm st,1024 # Assembler SourceFile B contains: .globl st[RW] .csect st[RW] .long 1 .long 2 # Using st in the above two programs refers to # Control Section st in Assembler SourceFile B.
/* This C module named td2.c */ extern long t_data; extern void mod_s(); main() { t_data = 1234; mod_s(); printf("t_data is %d\n", t_data); }
.file "mod2.s" .csect .mod_s[PR] .globl .mod_s[PR] .set RTOC, 2 l 5, t_data[TD](RTOC) # Now GPR5 contains the # t_data value ai 5,5,14 stu 5, t_data[TD](RTOC) br .toc .comm t_data[TD],4 # t_data is a global symbol
as -o mod2.o mod2.s cc -o td2 td2.c mod2.o
t_data is 1248
The .align pseudo-op, .csect pseudo-op, .globl pseudo-op, .lcomm pseudo-op, .long pseudo-op.