Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!rice!uw-beaver!cornell!wayner From: wayner@cello.cs.cornell.edu (Peter Wayner) Newsgroups: comp.sys.mac.programmer Subject: Re: Increment (Was Re: Pascal deficiency)? Message-ID: <49832@cornell.UUCP> Date: 18 Dec 90 02:18:42 GMT References: <1990Dec17.160242.5095@phri.nyu.edu> <1990Dec17.172613.7941@cs.umn.edu> <1990Dec18.001753.3756@Neon.Stanford.EDU> Sender: nobody@cornell.UUCP Organization: Cornell Univ. CS Dept. Ithaca NY Lines: 45 kaufman@Neon.Stanford.EDU (Marc T. Kaufman) writes: >In article ewright@convex.com (Edward V. Wright) writes: >>In <1990Dec17.172613.7941@cs.umn.edu> sec@cs.umn.edu (Stephen E. Collins) writes: >>Actually, this would have to be >->x++: LOAD X >-> INC X >-> STORE X >>Unless you have an instruction to increment variables in memory! >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) This is good information, but how many cycles does each of these take? They are both going to memory, incrementing and returning a value. I suspect that the latest versions of the 68040 will heavily pipeline this operation, perhaps, but it is not clear that just using one instruction is faster than using 3. There are many examples from the fine old VAX where it was faster to use 3 simple instructions instead of one super-duper one. This observation was the impetus for the RISC movement. So what is it? Anyone have a 680?0 manual handy? Peter Wayner Department of Computer Science Cornell Univ. Ithaca, NY 14850 EMail:wayner@cs.cornell.edu Office: 607-255-9202 or 255-1008 Home: 116 Oak Ave, Ithaca, NY 14850 Phone: 607-277-6678