Re: Comparing the absolute values.



"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./.

.



Relevant Pages

  • Re: Comparing the absolute values.
    ... but I'd like to avoid this sort of solution ... you should *not* need to compare absolute values. ... replicate the routine for the various sectors, ...
    (comp.lang.asm.x86)
  • Re: Reading UDTs out of a byte array (CopyMemory vs Get on a disk file)
    ... >> It is a cheat, and slightly naff, but you are currently at risk of ... Compare FileDateTimes between the NW version and the local one ... as far as your routine is concerned it is reading the data from the ... If you really want to fill the UDT with directly from the Byte Array ...
    (microsoft.public.vb.winapi)
  • Compare two sheets and perform action routine
    ... I'm trying to compare two sheets with a routine. ... Dim iCtr As Integer ... Dim lastrowquery As Integer ...
    (microsoft.public.excel.programming)
  • Re: obvious absolute
    ... call "absolute whatever" is actually "proper whatever". ... the local ether is the local effect of all the masses of the universe. ... that is called the absolute speed of the object, how can one compare it ...
    (sci.physics.relativity)
  • Re: 4x4 debate - what HAVE you people got against Doug???
    ... they were saying: ... That's an absolute "worst case", ... greenwash. ... compare every 4x4 against an equivalently powered 2wd I look forward ...
    (uk.transport)