Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!apple.com!alexr From: alexr@apple.com (Alex Rosenberg) Newsgroups: comp.sys.mac.programmer Subject: Re: Pascal deficiency? Message-ID: <47492@apple.Apple.COM> Date: 19 Dec 90 18:27:56 GMT References: <0B010004.o0u3z7@outpost.UUCP> Sender: alexr@Apple.COM Organization: Hacker's Anonymous Lines: 68 In article <0B010004.o0u3z7@outpost.UUCP> peirce@outpost.UUCP (Michael Peirce) writes: > Here are the two sources: > > The Pascal Source - > > UNIT Test; > > INTERFACE > > PROCEDURE testit(x:LONGINT); > > IMPLEMENTATION > > PROCEDURE SomeThing(a,b: LONGINT); EXTERNAL; > > PROCEDURE Testit(x:LONGINT); > VAR > i : LONGINT; > BEGIN > FOR i := 1 to 10 DO BEGIN > SomeThing(i,x); > END; > END; > > END. > > And the MPW C source - > > void SomeThing(int a, int b); external; > > void test(int x) > { > int i; > > for (i=1;i<= 10;i++) { > SomeThing(i,x); > } > }; The MPW C case can be optimized like: void test(int x) { int i; for (i=10; i; --i) { SomeThing(i,x); } }; MPW C should end up using a DBRA loop for this, which uses less instructions. Note the predecriment, as in MPW C, prefix operations on register-based variables (as "i" should is) are tighter than postfix. (Note that while I think that the Pascal compiler can generate DBRA loops, I'm not sure it will in this case.) By far, the handiest tool for this sort of investigation is UltraSlimFast. This MPW tool can be found on the System 7.0 Beta CD. It prints object code next to the source code, matching lines up as much as possible. --------------------------------------------------------------------------- - Alexander M. Rosenberg - INTERNET: alexr@apple.com - Yoyodyne - - 330 1/2 Waverley St. - UUCP:ucbvax!apple!alexr - Propulsion - - Palo Alto, CA 94301 - - Systems - - (415) 329-8463 - Nobody is my employer so - :-) - - (408) 974-3110 - nobody cares what I say. - -