Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!munnari.oz.au!uniwa!vax7!nlewispn From: Lewis_P@cc.curtin.edu.au (Peter Lewis) Newsgroups: comp.sys.mac.programmer Subject: Re: Increment (Was Re: Pascal deficiency)? Message-ID: <5149.276e0e0b@cc.curtin.edu.au> Date: 18 Dec 90 04:39:38 GMT References: <1990Dec17.160242.5095@phri.nyu.edu> <1990Dec17.172613.7941@cs.umn.edu> <1990Dec18.001753.3756@Neon.Stanford.EDU> Organization: Curtin University of Technology Lines: 45 In article <1990Dec18.001753.3756@Neon.Stanford.EDU>, kaufman@Neon.Stanford.EDU (Marc T. Kaufman) writes: > Well, since we ARE in a Mac group, lets just look at the code MPW C generates > for just such constructs: > > i = i+1; > MOVE.L i,D2 > ADDQ.L #$1,D2 > MOVE.L D2,i > > i++; > MOVE.L i,D2 > ADDQ.L #$1,i > > ++i; > ADDQ.L #$1,i > > Behold. The 68K does, indeed, have an instruction to increment variables in > memory. > > Marc Kaufman (kaufman@Neon.stanford.edu) Since the discusion was started because of the deficiency in Pascal of not having the ++ operator (which, BTW, I agree is a deficiency), I thought it would be interesting to see what THINK Pascal produced. In fact, TP compiles thusly ... var i:integer; begin i:=1; { MOVEQ #1,D7 } i:=i+1; { ADDQ.W #1,D7 } end. So much for C being more efficient than Pascal :-). Of course as someone else pointed out, these are toy examples, and comparing MPW C to THINK Pascal is a bit iffy (someone like to tell us what THINK C produces (with/without a register statement)). But its interesting ... Peter. -- Disclaimer:Curtin & I have an agreement:Neither of us listen to either of us. *-------+---------+---------+---------+---------+---------+---------+-------* Internet: Lewis_P@cc.curtin.edu.au I Peter Lewis ACSnet: Lewis_P@cc.cut.oz.au I NCRPDA, Curtin University Bitnet: Lewis_P%cc.curtin.edu.au@cunyvm.bitnet I GPO Box U1987 UUCP: uunet!munnari.oz!cc.curtin.edu.au!Lewis_P I Perth, WA, 6001, AUSTRALIA Hack: ResEdit ResEdit 2.0b2, change CODE=5, 00091C: 4EBA 02A4 to 4E71 4E71