Re: No xor!!
On Tue, 27 Oct 1998 00:01:53 -0500, one of the children, Matt Z
Nunyabidness <matt1278 at JUNO.COM>, wrote:
>Why is there no xor operator, imp, or eqv? How do you xor stuff if you
>don't have it???
xor can be simulated with perfect accuracy by using
((a !=3D 0) !=3D (b !=3D 0))
where a and b are the desired operands.
I don't remember the truth tables for imp, so I can't give you
the equivalent.
eqv is ((a !=3D 0) =3D (b !=3D 0))
Instead of learning operators by rote, take the time to try to
understand what they do, and see if there are other ways to do
them.
I've seen information that suggests (and my own experience tends
to confirm) that a useful computer could be built with a single
machine-code instruction that takes two operands: SSJZ,
Subtract/store/jump-if-zero. It subtracts its first operand from
its accumulator, stores the result back into the current memory
location, and jumps to the address specified in the second
operand, if the result of the subtract was zero. Given that
operand, I was able to come up with most of the other operations
that would need to be implemented for a "sensible" instruction
set, enough to simulate most of the structures needed for
implementing a HLL such as Pascal.
You don't need every instruction that BASIC supplies to write
equivalent code in another language. Learn to write code in the
language you're using; don't try to write BASIC in that language.
--
Jeff Zeitlin
jzeitlin at cyburban.com
|
Not Categorized, Please Help
|
|