The CREF Utility

The CREF cross-reference utility CREF.EXE processes a .CRF file produced by MASM, creating an ASCII text file with the default extension .REF. The file contains a cross-reference listing of all symbols declared in the program and the line numbers in which they are referenced. (See Figure 4-5.) Such a listing is very useful when debugging large assembly-language programs with many interdependent procedures and variables.

CREF may be supplied with its parameters interactively or in a single command line. If you enter the utility name alone, CREF prompts you for the input and output filenames, as shown in the following example:

C>CREF <Enter>

Microsoft Ò Cross-Reference Utility Version 5.10

Copyright Ó Microsoft Corp 1981-1985, 1987. All rights reserved.

Cross-reference [.CRF]: HELLO <Enter>

Listing [HELLO.REF]:

15 Symbols

C>

Microsoft Cross-Reference Version 5.10 Thu May 26 11:09:34 1988

HELLO.EXE --- print Hello on terminal

Symbol Cross-Reference (# definition, + modification)Cref-1

@CPU . . . . . . . . . . . . . . 1#

@VERSION . . . . . . . . . . . . 1#

CODE . . . . . . . . . . . . . . 21

CR . . . . . . . . . . . . . . . 17# 46 47

DATA . . . . . . . . . . . . . . 44

LF . . . . . . . . . . . . . . . 18# 46 47

MSG. . . . . . . . . . . . . . . 33 46#

MSG_LEN. . . . . . . . . . . . . 32 49#

PRINT. . . . . . . . . . . . . . 25# 39 60

STACK. . . . . . . . . . . . . . 23 54# 54 58

STDERR . . . . . . . . . . . . . 15#

STDIN. . . . . . . . . . . . . . 13#

STDOUT . . . . . . . . . . . . . 14# 31

_DATA. . . . . . . . . . . . . . 23 27 44# 51

_TEXT. . . . . . . . . . . . . . 21# 23 41

15 Symbols

Figure 4-5. Cross-reference listing HELLO.REF produced by the CREF utility from the file HELLO.CRF, for the HELLO.EXE program example from Chapter 3. The symbols declared in the program are listed on the left in alphabetic order. To the right of each symbol is a list of all the lines where that symbol is referenced. The number with a # sign after it denotes the line where the symbol is declared. Numbers followed by a + sign indicate that the symbol is modified at the specified line. The line numbers given in the cross-reference listing correspond to the line numbers generated by the assembler in the program-listing (.LST) file, not to any physical line count in the original source file.

The parameters may also be entered in the command line in the following form:

CREF CRF_file, listing_file

For example, the command-line equivalent to the preceding interactive session is:

C>CREF HELLO,HELLO <Enter>

If CREF cannot find the specified .CRF file, it displays an error message. Otherwise, it leaves the cross-reference listing in the specified file on the disk. You can send the file to the printer with the COPY command, in the following form:

COPY listing_file PRN:

You can also send the cross-reference listing directly to a character device as it is generated by responding to the Listing prompt with the name of the device.