How to write ANY value

A

Anders Wegge Keller

Keith Thompson said:
Anders Wegge Keller said:
In the general case, adress 0x0842 has no universal meaning beyond
beaing an address. Thus, we never get to the point of having to worry
about different compilers ways with memory access.
[...]

In the general case, 0x0842 is not an address at all; it's of
type int. It can be *converted* to some pointer type, and such
a conversion is "intended to be consistent with the addressing
structure of the execution environment".

Sorry for not being nit-picky enough do write (unsigned char
*0x0842). Quoting one of my colleagues, when we were at a Coccinelle
workshop "We're not C-linguists. We just use the language".
We often refer to things like " address 0x0842", but that's either a
convenient verbal shorthand for the above conversion, or something
outside the scope of the C language. (Address 0x0842 might well
be a meaningful concept in the context of a particular CPU.)

A lot of the things we do with C *is* outside the language proper. At
least, that's the case for me, and I expect that more and more of the
remaining C development is targeted at either freestanding
implementations in toasters etc. or low-level bit banging.

That will give some imprecise language that isn't proper in this
group, but please bear with me. I'm doubly challenged by also not
being a native english speaker.
 
E

Eric Sosman

[...]
A lot of the things we do with C *is* outside the language proper.

Yes, and the Rationale recognizes this explicitly. So does the
Standard itself, albeit only in non-normative material.

There is nothing -- *nothing* -- wrong with crossing the line
between fully portable C and system-specific C. In my opinion, it
is both common and laudable to cross that line at need. But in my
opinion it is also important to know where the line is, to know what
parts of the code will require effort to port and what parts will
"port themselves," and to take appropriate precautionary measures.
Like, for example, wrapping those `volatile' pointer-from-integer
constructs inside easily-segregated functions instead of just letting
them float free throughout the code. You questioned BartC's advice
to "be wary" of raw access to memory-mapped registers; I think his
wariness is good engineering practice.
At
least, that's the case for me, and I expect that more and more of the
remaining C development is targeted at either freestanding
implementations in toasters etc. or low-level bit banging.

I betcha, I betcha, I betchamillionbucks that next year's toaster
will use a different CPU. Quite likely (but not certainly) a CPU in
the same family as this year's, but enhanced/cost-reduced/spiffed-up
in some way or other. And, lo! the code will have to be ported.

We have arrived at a situation where "soft"ware is something of a
misnomer. It used to be "soft" because it was malleable, it could be
changed cheaply without modifying the expensive and hard-to-change
hardware that it ran on. Well, nowadays the "hard"ware changes have
become faster than they were, while "soft"ware changes have grown more
and more difficult. An investment in "soft"ware can only be justified
if it can be amortized over several generations of "hard"ware -- or, in
short, your code *will* be ported. If you do not prepare for that
inevitability, you make yourself a net resource drain and not a net
contributor.

As for bit-banging -- well, I liked your earlier message about
"bit-baning" better! Bits have been the bane of most of us, and I
imagine they'll continue to be so. :)

(A European colleague once gave me his business card, which
described him as a "System-Berater," a German title we might render in
English as "System Advisor" or "System Consultant." But the English
verb "berate" means to scold or chastise, and I immediately pictured
the fellow wagging an admonitory forefinger at a recalcitrant computer
and saying "Bad system! Baaadddd system! No dessert for you!!!")
That will give some imprecise language that isn't proper in this
group, but please bear with me. I'm doubly challenged by also not
being a native english speaker.

Anders, your English is one helluvalot better than my Norwegian!
There's a saying: If you speak many languages you're "multilingual,"
if you speak two languages you're "bilingual," and if you speak one
language you're "American."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,085
Messages
2,570,597
Members
47,218
Latest member
GracieDebo

Latest Threads

Top