Sender: nate AT cartsys DOT com Message-ID: <35BD6187.A151342E@cartsys.com> Date: Mon, 27 Jul 1998 22:28:39 -0700 From: Nate Eldredge MIME-Version: 1.0 To: "Salvador Eduardo Tropea (SET)" CC: EDWARD CASHIN , djgpp AT delorie DOT com Subject: Re: implementation of modulo operator in djgpp References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Precedence: bulk Salvador Eduardo Tropea (SET) wrote: > > EDWARD CASHIN wrote: > > ...which begs the question, "How fast is the modulo?" > > and more specifically, how is it implemented? > > Modulo is just the rest of a division. So if last is a variable (not a macro > and not a constant) you'll get a div or idiv and that's sllloooowwww. > But I think you must call gcc with -S to take a look at the generated > assembler ;-) True. Suggested optimization: Make the buffer size a power of 2. Then do: front = (front + 1) & (size - 1); -- Nate Eldredge nate AT cartsys DOT com