Example using .comm pseudo-op with td storage-mapping class
The source for the C main program td2.c
- The following is the source for the C main program td2.c:
/* 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); }
- The following is the assembler source for module mod2.s:
.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
- The following commands assemble and compile the source programs
into an executable td2:
as -o mod2.o mod2.s cc -o td2 td2.c mod2.o
- Running td2 prints the following:
t_data is 1248