Re: Ambiguities in VRML-Syntax

Antmeopohedron ([email protected])
Mon, 4 Dec 1995 16:19:53 -0500 (EST)


} Richard:
}
} Under some compilers, your code
} >>which is much clumsier than saying:
} >>whatever variable = 2 * boolean variable;
} Will besak. I've seen systems where TRUE is anything NOT = 0, and is
}'undefined' as an exact value. Also, I've heard of systems where FALSE was -1,
} and true was 0. (strange, but true)
}
} Besides, the IF statement will compile much smaller than the multiplication
} (even under an optimizing compiler).

Say what? An if statement requires at a minimum a branch instruction and an
instruction for each of the assignments, plus an unconditional jump after
one of the assignments, four instructions, i.e.

BRANCH on <boolean> to <true clause>
STORE <variable> value 0
JUMP to <end of true clause>
true clause:
STORE <variable> value 2
end of true clause:

A multiply will by one instruction if the multiply instruction can do its
own memory storing, two if it can't:

MULTIPLY <boolean> by 2 into <register or <variable>>
#and, if MULTIPLY does not do memory storage:
STORE <variable> from <register>

In addition, execution speed is slowed by a branch instruction due to
today's pipelined RISC chips. There are advantages to the MULTIPLY over the
IF, *especially* if this code will be run (looped, most likely) over and
over. This is a hand optimization, not something the compiler can do. Do we
want efficient coding techniques available, or do we simply want to count
on unlimited computing power?

<UNNECESSARY AND FRUSTRATED FLAME>
Take a class on it and try again!
</UNNECESSARY AND FRUSTRATED FLAME>

} == John ==
--Greg


  • Next message: Antmeopohedron: "Re: Ambiguities in VRML-Syntax"
  • Previous message: Richard Rabbat: "Re: Role of copyright in innovation"