09.06.2013 Views

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

Intel XENIX 286 Programmers Guide (86) - Tenox.tc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>XENIX</strong> Programming cc: C Compiler<br />

To create an assembly language listing, give the name of the desired source file. For<br />

example, the command<br />

cc -5 add.c<br />

creates an assembly language listing file named add.s and the command<br />

cc -L mult.c<br />

creates a listing file named mult.L. Note that both the -S and -L options suppress<br />

subsequent compilation of the source file; they imply the -c option. Thus, no program<br />

file is creat ed and no linking is performed.<br />

Another use of the -S option is to create an assembly language source file that may be<br />

optimized by hand and later submitted to masm for translation. Although this method<br />

can be useful, optimizing should be left to the compiler whenever possible.<br />

The -S and -L options apply to source files only; the compiler cannot create an assembly<br />

language listing file from an existing object file. Furthermore, the options in the<br />

command line must appear before the names of the files for which the assem bly listings<br />

are to be saved.<br />

Profiling a Program<br />

You can examine the flow of execution of a program by adding "profiling" code to the<br />

program with the -p option. The profiling code automatically keeps a record of the<br />

number of times program functions are called during execution of the program. This<br />

record is written to the mon.out file and can be examined with the prof command.<br />

For example, the command<br />

cc -p main.c<br />

adds profiling code to the program created from the source file main.c. The profiling<br />

code automatically calls the monitor function, which creates the mon.out file at normal<br />

termination of the program. The prof command is described in Appendix B,<br />

"Programm ing Commands." The monitor function is described in "System Functions" in<br />

the <strong>XENIX</strong> <strong>2<strong>86</strong></strong> C Library <strong>Guide</strong>.<br />

The -p option must be given in any command line that links object files containing<br />

profiling code. For example, if the command<br />

cc -c -p f1.c f2.c<br />

was used to create the object files fl.o and f2.o, then the command<br />

cc -p f1.o f2.o<br />

must be used to create an executable program from these files.<br />

2-11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!