Mail Archives: djgpp/1997/10/28/22:16:49

Date: Tue, 28 Oct 1997 19:16:12 -0800 (PST)
Message-Id: <>
Mime-Version: 1.0
To: Eder James <st3edej AT doc DOT ntu DOT ac DOT uk>, djgpp AT delorie DOT com
From: Nate Eldredge <eldredge AT ap DOT net>
Subject: Re: ASM and graphics

At 09:58  10/28/1997 GMT, Eder James wrote:
>Hi, all.
>Got a quick question that I'm sure somebody can help me out with.
>I have implemented some graphics (mode 13h) functions using AT&T asm, an
>example being a pixel plot function.
>To calculate the offset of the pixel to be drawn, the maths needed is along
>the lines of :
>Offset = (Y * 320) + X
>The bit I'm interested in here is the (Y * 320) part of the equation.
>Which of the outlined partial implementations would prove the fastest in
>terms of execution ?
>Using multiply....
>movl	_Y_Pos, %eax
>imull	$320, %eax
>...or using shift...
>movl	_YPos, %eax
>movl	%eax, %ebx
>shl	$6, %ebx
>shl	$8, %eax
>addl	%ebx, %eax
>I would like to know which is the quicker as I believe the mul and div are
>slow on the Intel Pentium processors.
>Any help appreciated.
Questions of this sort are always tough because instruction timings can
differ greatly on different processors, and there are N different types out
there. I would *guess* (no flames, please!) that the shifts would be faster.
The very best way to find out is by trying it both ways and profiling.

Nate Eldredge
eldredge AT ap DOT net

- Raw text -

  webmaster     delorie software   privacy  
  Copyright 2019   by DJ Delorie     Updated Jul 2019