On 2/21/2011 2:36 PM, aleksa wrote:
> On Feb 21, 8:05 pm, Keith Thompson<ks...@mib.org> wrote:
>> #define ARBITRARY_DATA 42
>> *p = ARBITRARY_DATA;
>
> I was actually trying to avoid that approach,
> because it requires the CPU to load a register with a
> specific value, which isn't really necessary.
>
> As I said to Jens:
> "Writing whatever value is stored at that moment in whatever CPU
> register",
> without the need to initialize it first.
There's no way to do this in C. There may be ways to do it in
a particular implementation of C, with a particular set of compiler
options, under a particular set of conditions that enable or prevent
particular optimizations, if you're a left-handed seventh son of a
seventh son programming in an abandoned churchyard by the light of
the second full Moon of an odd-numbered month.
(In short, if you're counting the individual instructions that
the machine executes to carry out the intent of your code, C is not
the way to express that intent. Wrong tool; use another.)
--
Eric Sosman
d