Chris Croughton said:
Several popular compilers will warn you about that if you enable
warnings, because the condition can never be true so the statements
after it are unreachable.
If that's what you mean then do it -- but if len is larger than MAXINT
it will have undefined effect so you need to check for that first.
Yep. The ugly thing gets in.
And is totally non-portable. Even between assemblers for the same
platform.
True, but for an experienced programmer such as I am, converting most of the
source between TASM, MASM, NASM, (G)AS, etc etc, isn't a problem, rather a
straightforward excersize.
But different people find different parts of it counter-intuitive,
that's the problem, and same is true for all other programming
languages. Including asssembler.
NOT R1
BIC R1, R0
instead of
AND R1, R0
While I understand what NOT and AND usually mean and do, BIC isn't in my
vocabulary. What is it? BIt Clear, clears the specified pattern of bits?
I'm not sure I see the point here other than doing essentially the same
thing two slightly different ways.
And many other oddities which only make sense if you know a particular
processor in detail.
That's fine
Sigh.
And would confuse many more. C was written for systems programmers,
largely, and so was designed tro do what you told it and nothing more.
That's how every language and machine work. All errors are commited by the
engineers because when they fail translate the idea/algorithm into machine
language. I don't see a problem here. Actually, having both signed and
unsigned integer types in any language would be that "more" thing as most
CPUs don't differentiate the two, it's not needed in 2's complemented
addition, subtraction, comparison... The CPU simply sets/clears the carry
and overflow flags and it is the programmer to give the meaning to these
flags and sign bits. The sign starts matter when we do conversion to longer
types (as it needs replication) and in multiply/divide/modulo operations.
The rest, the bit logic, is the bit logic, it shouldn't and doesn't care
about the meanings of the MSBits.
So if you want to do some conversions other than the default, you do
them. C is not designed for mathematics (try FORTRAN -- "FORmula
TRANslation"), so you get 1/2 == 0 because that is what is expected in
integer arithmetic even though it isn't in mathematics, and if you then
assign the result to a floating point variable it sets it to zero.
That's fine. Actually, any decent mathematicion must understand this.
It's certainly not perfect, at least one of the original authors of the
language has admitted that the precedence of some of the operators was
wrong,
like in:
if (a & b == c) {}
?
but there is by now no chance of changing it because there is too
much code which depends on it. Just as with natural language, we can't
just change English spelling to something more lojikal at a wim, evn tho
sum pepl hav trid to do that.
Wel, if ju rimuv ol thi unnidid nd komplikeitid stuf from thi langwidj, it'l
bicum unridbl. Or turn in to something closer to, say, German.
Except it's worse with computer languages
because you can probably understand what I wrote where a compiler
can't...
Ah stupid compilers...
There's a joke in our company... Q: how to make
such code, adding to which -10 dB of noise (or 32% of errors/bugs
, would
still compile and work properly?
(And yes, I know that the Cyrillic alphabet did have several letters
removed as an act of the government, but that can only be done when the
government can say that all books in the previous script have to be
replaced and be obeyed...)
If that was done to English, the world would benefit. But it can't be done
because the price would IMO be even bigger contextuality. Currently, at
least the spellings of different things are different. Can't imagine they
would be identical. The whole language would need changes.
Alex