Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!dalcs!dalcsug!dalegass From: dalegass@dalcsug.UUCP Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Turbo C 'optimization' Message-ID: <126@dalcsug.UUCP> Date: Sat, 15-Aug-87 09:26:53 EDT Article-I.D.: dalcsug.126 Posted: Sat Aug 15 09:26:53 1987 Date-Received: Sun, 16-Aug-87 09:33:39 EDT Organization: Dalhousie University, Halifax, N.S., Canada Lines: 59 Keywords: Is it any good? Xref: utgpu comp.sys.ibm.pc:5922 comp.lang.c:3499 Does anyone have views regarding the quality of code generated by Turbo C? It claims to be one of the best around, but I've seen some code generated that I consider rather disappointing. I think my main gripe would be the code generated by the basic multiply and divide operations. For example, consider the following code fragment: long long_mult(int i, int j) { long k; k = (long) i * j; return k } Whereas Aztec C would produce code something along the lines of: MOV AX,_i MUL _j Turbo C generates something like this: MOV AX,_i CWD PUSH DX PUSH AX POP BX POP CX PUSH CS CALL LXMUL@ I consider this to be a pretty basic requirement, and doing a call for a multiply is a bit much, in my view. Even in long*long=long multiplications, Aztec C simply puts a couple of IMUL's and ADDs inline. Similarly, I would like int i,j; long k; i = (int) (k / j) to simply use the IDIV instruction once, rather than a call, as Turbo C does. This poor code generation (and resulting speed degredation) has led me to manually code time-critical parts of my programs into machine language, which I don't think should have been necessary (and isn't in Aztec C). One thing Turbo C does, that I consider to be important optimization is the way the peek() and poke() calls are translated into direct memory reads and writes, if you #include . This can really speed things up. Don't get me wrong: I think Turbo C is the best C development environment available, and I constantly use and enjoy the package. Hopefully Version 2.0 will do a little bit better optimization... -dalegass@dalcsug.uucp