SOFTWAREREViEWS; - IEEE Computer Society · SOFTWAREREViEWS; Editor PaulOman ... University of...

2
SOFTWARE REViEWS; Editor Paul Oman Computer Science Dept. University of Idaho c/o 1350 NW 19th St. Corvallis, OR 97330 Compmail+: poman Microsoft's venerable C compiler gets even better Harvey L. Howard III and Michael A. Simon, University of Idaho The Microsoft C compiler system is an excellent package for the serious C programmer. And the inclusion of the Codeview symbolic debugger with a compiler that comes close to the pro- posed ANSI C standards makes this new version (4.0) of the venerable PC compiler an extremely usable develop- ment package. Codeview's debugging facilities pro- vide an excellent learning tool as well as a quick and easy development tool. It is also a definite asset in debugging assembly-language programs. The source code for Microsoft C is easily transported to other hosts' com- pilers. We were able to compile about 10,000 lines of standard C code with this compiler, the Eunice C compiler on a VAX 11/780, and the HP-UX C com- piler on a HP-9000 system - without any code modifications. (The 10,000 lines of code were a major full-screen editor and a file-management system plus various other small programs.) Interface. The new Version 4.0 is very easy to use and follows the form of previous Microsoft assembler and com- piler products. The MSC compiler for MS-DOS-experienced developers produces .OBJ object files that are then linked to create .EXE executable files the same way that Microsoft's com- pilers for other languages do. Microsoft C can be used interactively or through a command line input. All options in MSC may be prefixed with /. For Unix-experienced developers, the package includes an alternate version of the compiler called CL (similar to the cc program on Xenix and Unix systems) that compiles and links the source file in one step. It also conforms to Kernighan and Ritchie standard C with minor exceptions noted in the documentation. CL produces the same .EXE files that MSC does, but it does so with the tradi- tional Unix interface. The CL libraries include more than 200 runtime library routines. These libraries are compatible with the Xenix 80286 and most of the Unix System V runtime library routines. The Microsoft C compiler and libraries support five basic memory models (small, compact, medium, large, and huge) that can be mixed for your applications. All options in CL may be prefixed with - Components. The compilers support the 8087 and the 80287 math coproces- sors and has an 8087/80287 emulator so you can develop coprocessor code with- out actually having a coprocessor in your machine. Register variables are also supported for optimization. There are 46 options to control the MSC compiler's actions. These options control coprocessor support, memory model used, generated list files, target CPU, optimization, debugging infor- mation, and window applications infor- mation. There is also a /Help option that will list the common options on the screen. Additional options are available for the CL version. The code generated is in standard DOS object code format for Microsoft Linker Version 3.0 and can be linked with Microsoft Fortran and Pascal Ver- sions 3.3 and higher and with Microsoft assembler. The executable code sup- IN BRIEF ports MS-DOS path names, I/O redirection, and record/file locking and file sharing for network support. Utilities. Version 4.0 includes several utilities: * LINK.EXE: A new version of the Microsoft Linker (Version 3.51). This linker supports the interactive Codeview debugger. This linker operates exactly the same as the previous versions. * LIB.EXE: A new version of the Microsoft library utility (Version 3.04). * MAKE.EXE: A new program to automate program-file updating. This program approximates the make utility in Unix. The command file format for the Microsoft make is not identical to the Unix command file format, but Microsoft's make is still versatile and easy to use. EXEPACK.EXE: This utility com- presses sequences of identical characters from an executable file and optimizes the relocation table. The original file is not destroyed. EXEMOD.EXE: This utility lets you modify the header of an .EXE file to change the stack size, minimum alloca- tion, and maximum allocation. You may also display the header without modifications. SETENV.EXE: This new utility modifies COMMAND.COM to increase the environment table size. This pro- gram will work with MS-DOS Versions 2.0 through 3.1 but should not be used for MS-DOS 3.2. (MS-DOS 3.2 has its own way to alter the environment table size.) This program may or may not work with other versions of MS-DOS. Debugger. Codeview is a window- oriented, source-level symbolic debug- ger for Microsoft C that will also oper- ate on any executable file at the assembly level (nonsymbolic). MSC with the /Zi /Od compiler options will produce an object file with symbolic information compatible with Codeview. The object code must be linked with the /Co option to include this symbolic information in the executable file. Figure I shows the initial Codeview IEEE Software 92

Transcript of SOFTWAREREViEWS; - IEEE Computer Society · SOFTWAREREViEWS; Editor PaulOman ... University of...

Page 1: SOFTWAREREViEWS; - IEEE Computer Society · SOFTWAREREViEWS; Editor PaulOman ... University of Idaho c/o1350 NW19th St. Corvallis, OR97330 Compmail+:poman Microsoft'svenerableCcompilergetsevenbetter

SOFTWAREREViEWS;Editor Paul OmanComputer Science Dept.University of Idahoc/o 1350 NW 19th St.Corvallis, OR 97330Compmail+: poman

Microsoft's venerable C compiler gets even betterHarvey L. Howard IIIand Michael A. Simon,University ofIdahoThe Microsoft C compiler system is

an excellent package for the serious Cprogrammer. And the inclusion of theCodeview symbolic debugger with acompiler that comes close to the pro-posed ANSI C standards makes thisnew version (4.0) of the venerable PCcompiler an extremely usable develop-ment package.

Codeview's debugging facilities pro-vide an excellent learning tool as well asa quick and easy development tool. It isalso a definite asset in debuggingassembly-language programs.The source code for Microsoft C is

easily transported to other hosts' com-pilers. We were able to compile about10,000 lines of standard C code withthis compiler, the Eunice C compiler ona VAX 11/780, and the HP-UX C com-piler on a HP-9000 system - withoutany code modifications. (The 10,000lines of code were a major full-screeneditor and a file-management systemplus various other small programs.)

Interface. The new Version 4.0 is veryeasy to use and follows the form ofprevious Microsoft assembler and com-piler products. The MSC compiler forMS-DOS-experienced developersproduces .OBJ object files that are thenlinked to create .EXE executable filesthe same way that Microsoft's com-pilers for other languages do. MicrosoftC can be used interactively or through acommand line input. All options inMSC may be prefixed with /.For Unix-experienced developers, the

package includes an alternate version of

the compiler called CL (similar to the ccprogram on Xenix and Unix systems)that compiles and links the source file inone step. It also conforms to Kernighanand Ritchie standard C with minorexceptions noted in the documentation.CL produces the same .EXE files thatMSC does, but it does so with the tradi-tional Unix interface.The CL libraries include more than

200 runtime library routines. Theselibraries are compatible with the Xenix80286 and most of the Unix System Vruntime library routines. The MicrosoftC compiler and libraries support fivebasic memory models (small, compact,medium, large, and huge) that can bemixed for your applications. Alloptions in CL may be prefixed with -

Components. The compilers supportthe 8087 and the 80287 math coproces-sors and has an 8087/80287 emulator soyou can develop coprocessor code with-out actually having a coprocessor inyour machine. Register variables arealso supported for optimization.

There are 46 options to control theMSC compiler's actions. These optionscontrol coprocessor support, memorymodel used, generated list files, targetCPU, optimization, debugging infor-mation, and window applications infor-mation. There is also a /Help optionthat will list the common options on thescreen. Additional options are availablefor the CL version.The code generated is in standard

DOS object code format for MicrosoftLinker Version 3.0 and can be linkedwith Microsoft Fortran and Pascal Ver-sions 3.3 and higher and with Microsoftassembler. The executable code sup-

IN BRIEF

ports MS-DOS path names, I/Oredirection, and record/file locking andfile sharing for network support.

Utilities. Version 4.0 includes severalutilities:

* LINK.EXE: A new version of theMicrosoft Linker (Version 3.51). Thislinker supports the interactive Codeviewdebugger. This linker operates exactlythe same as the previous versions.

* LIB.EXE: A new version of theMicrosoft library utility (Version 3.04).

* MAKE.EXE: A new program toautomate program-file updating. Thisprogram approximates the make utilityin Unix. The command file format forthe Microsoft make is not identical tothe Unix command file format, butMicrosoft's make is still versatile andeasy to use.EXEPACK.EXE: This utility com-

presses sequences of identical charactersfrom an executable file and optimizesthe relocation table. The original file isnot destroyed.EXEMOD.EXE: This utility lets you

modify the header of an .EXE file tochange the stack size, minimum alloca-tion, and maximum allocation. Youmay also display the header withoutmodifications.SETENV.EXE: This new utility

modifies COMMAND.COM to increasethe environment table size. This pro-gram will work with MS-DOS Versions2.0 through 3.1 but should not be usedfor MS-DOS 3.2. (MS-DOS 3.2 has itsown way to alter the environment tablesize.) This program may or may notwork with other versions of MS-DOS.

Debugger. Codeview is a window-oriented, source-level symbolic debug-ger for Microsoft C that will also oper-ate on any executable file at theassembly level (nonsymbolic). MSCwith the /Zi /Od compiler options willproduce an object file with symbolicinformation compatible with Codeview.The object code must be linked with the/Co option to include this symbolicinformation in the executable file.Figure I shows the initial Codeview

IEEE Software92

Page 2: SOFTWAREREViEWS; - IEEE Computer Society · SOFTWAREREViEWS; Editor PaulOman ... University of Idaho c/o1350 NW19th St. Corvallis, OR97330 Compmail+:poman Microsoft'svenerableCcompilergetsevenbetter

_ Fi le Search Vie. Run Watch Options Call s Trace Go! sieve. exesieve.Cl

22:l23: count =0;24: for( i 0; i <= SIZE; i+) set alI f lags true25: fflagsti] = TRUE;26:27: for( i = 2; i <= SIZE; i++ )28:{29: if flagsi ) /* found a prime /30: X31: for ( k = i + i; k = SIZE; k += i ) 532: f lags.k] = FALSE; /*Canc5

34:35:}i

36:37:38: printf (I%d prises\n', count);39:

Microsoft (R) CodeView (TM) Version 1.00Copyright (C) Microsoft Corp 1986. All rights reserved. 8

Figure 1. Initial screen in the Codeview debugger. Figure 2. Codeview initial screen with assembly lan-guage, dynamic-register window, and watch windowdisplayed.

screen for a demonstration programSIEVE.C included in the package. Thescreen is exactly like you see it whenfirst entering the debugger except thatfor demonstration purposes we havestepped through the program to line 33to provide a clearer picture of exactlywhat the debugger can do. All com-mands for Codeview can be enteredthrough the keyboard (keypad andfunction keys), with a mouse (only theMicrosoft mouse is guaranteed towork), or through dialogue commandsfrom the keyboard.Program execution is controlled in

four ways for source-line or assembly-language execution. Trace mode exe-

cutes one source line or one machineinstruction at a time. The mode willtrace functions, procedures, and inter-rupts. Program-step mode executes one

source line or one machine instructionat a time, but it will not trace functions,procedures, or interrupts. Go mode exe-

cutes the program until the end or untilit encounters a breakpoint. Executemode runs the program in slow motionso you can follow the complete execu-

tion at about one source line per sec-ond. There is also a Restart instructionthat lets you restart a program from thebeginning and keep all existing break-points and variable monitors.As many as 20 breakpoints can be set

within each program. Breakpoints canbe set at a source-line number, a func-tion or procedure description, or at a

specific address. Pass counts can also beset for each breakpoint. Breakpointscan be disabled to speed debugging andthen reenabled as required. Breakpointscan also be cleared to make additionalbreakpoints. You can also set a condi-tional breakpoints called watchpointsand tracepoints. Watchpoints are

expressions that will activate a break-point when the expression becomestrue. Tracepoints activate a breakpointwhen an expression or a range of mem-ory changes value. You can also displaya variable, range of memory, or an

expression during program executionand watch its value change dynamically.Codeview also lets you display and

modify variables, data and code mem-ory, and all registers. You can also dis-play registers in a math coprocessor,but you cannot modify them.

Figure 2 shows the Codeview screen

at the same line in the same program asin Figure 1, except the source windowhas been changed to show assembly lan-guage, the dynamic register window,and the watch window to show dynamicvariables. The assembly-language dis-play corresponds directly with the Csource code as lines 32 through 38clearly indicate, each followed by itsassociated assembly code. The break-points we set for lines 33 and 38 areindicated by the comments ;BRO and;BRI in the assembly listing.The dynamic register window is con-

tinuously updated during program exe-cution. The status of the CPU flags isalso displayed at the bottom of the reg-ister list.

In the watch window, above thesource window, we have displayed thevariables i, k, and flags[k]. Item 3 inthis window is a watchpoint, which willcause a break when k equals 200. Thevalues displayed for each variable are

continuously updated during programexecution.

In the dialogue window (at the bot-tom of Figure 2) are some examples ofdialogue commands to set watch expres-sions for variables and a watchpoint fora conditional break. These commands

are also accessible through the pull-down menus at the top of the screen.

Documentation. The documentationis easy to use by both the novice andexperienced user. For example, install-ing the system on a hard disk, whichincludes modifying the CONFIG.SYSfile, creating directories, getting the cor-rect files in their proper directory, andsetting up the correct environment spec-ifications for Lib, Include, and Tmp, isexplicitly detailed in the user's guide.

Problems. Codeview sets screen-colorattributes that remain even when youleave the module (even after exit toDOS). These color parameters are notreset, and users apparently have no con-trol over the colors that Codeview uses.In our case, the Codeview's colors aregreen background with pink letters (weused the AST-3G EGA board).We could not get our Logitech C7

mouse to work with Codeview butMicrosoft guarantees only thatCodeview will work with the Microsoftmouse.Jim Mullens from Oak Ridge

National Lab reported on ARPAnetand Bitnet that there is a problem withthe getch and ungetch commands. Ifyou getch a character, then ungetch it,and then later getch it again, the charac-ter is not echoed to the screen on thesecond getch. Our tests confirmed thiserror.

In the README.DOC file of notes,updates to the manuals, and minorproblems, Microsoft mentions a possi-ble problem when running Codeviewand Borland's Sidekick or Superkey atthe same time due to an incorrect resto-ration of the screen by Sidekick andtrapping of control keys by Superkey.

September 1987

- File Search View Run Watch Options Calls Trace! Go! sieve.exe

0) i 2 AX = 00101 )k 36 BX = 00012) f lagsok] : 1 CX = 00013 ) k = = 200 0 DX = 2390

SP = 2F6832: f lagsk] = FALSE; BP = 2F745416:0093 C685520000 MOV Byte Ptr tk+_flags,00 SI = 00025416:0098 E9F3FF JMP _main+7e (008E) DfEl = 002433: count++; DS = 55581WffiRNEO ec ;; . !; _ ! !i X s a! gss ES = 555835: SS = 55585416:009E E9CFFF JMP _main+60 (0070) | CS = 541636: } IP = 00935416:00A1 E997FF JmP _main+2b (003B) novrf low38: printf ("%d pri-es\n,. count); up5416:00A4 FF76FE PUSH Word Ptr (count] ;BRI enable5416:00A7 864600 MOV AX,0046 nngate5416:OOAA 50 PUSH AX not zero

auxcarry>w? k odd>w? flagstk] -Xcarry>wp? k == 200

93