Re: Comparing the absolute values.
- From: Phil Carmody <thefatphil_demunged@xxxxxxxxxxx>
- Date: 10 Jul 2007 00:54:08 +0300
"robertwessel2@xxxxxxxxx" <spamtrap@xxxxxxxxxx> writes:
On Jul 7, 6:21 pm, João Jerónimo <spamt...@xxxxxxxxxx> wrote:
I want to implement the Basenham's line drawing algorithm, so I will need
to compare the absolute values of two numbers (because the slope is
calculated by dividing the minor axes by the major axis)...
I want some efficient way to this in ASM, cause I'm writing the routine in
ASM... Of course I can just see how many of them are negative and then
choose the correct algorithm, but I'd like to avoid this sort of solution
(using something that avoids branching)...
If you care enough about performance to do Bresenham's in assembler,
you should *not* need to compare absolute values. You need to
replicate the routine for the various sectors, and just do the add/
compare (or subtract/compare) sequence as appropriate for each one.
Typically you end up with four or eight versions for the different
sectors.
It's over a decade since I did anything like that, but I'm sure
the easiest thing was to make things entirely data driven, such
that I did end up with only one version of the routine. In
particular when { min(a,b), max(a,b) } is so easy to calculate
quicky using MOVcc and suchlike.
One of course can then head down the philosophical route of
questioning whether the line from (a,b) to (c,d) is the same
as the line from (c,d) to (a,b) or not. Typically with data-
driven routines, you'd end up with the answer 'yes', but that
wouldn't be the right answer for all applications.
Phil
--
"Home taping is killing big business profits. We left this side blank
so you can help." -- Dead Kennedys, written upon the B-side of tapes of
/In God We Trust, Inc./.
.
- Follow-Ups:
- Re: Comparing the absolute values.
- From: robertwessel2@xxxxxxxxx
- Re: Comparing the absolute values.
- References:
- Comparing the absolute values.
- From: João Jerónimo
- Re: Comparing the absolute values.
- From: robertwessel2@xxxxxxxxx
- Comparing the absolute values.
- Prev by Date: Re: [Clax86list] 64bit operations efficiency...
- Next by Date: Re: [Clax86list] 64bit operations efficiency...
- Previous by thread: Re: Comparing the absolute values.
- Next by thread: Re: Comparing the absolute values.
- Index(es):
Relevant Pages
|