K
Kenny McCormack
[snip]Rod Pemberton said:You should ignore any response Healthfield gives to your question.
That's really bad advice.
Said Tweedle Dee of Tweedle Dumb.
[snip]Rod Pemberton said:You should ignore any response Healthfield gives to your question.
That's really bad advice.
Richard said:.... snip ...
Note that the term "RDTSC" is meaningless unless you happen to be
using an Intel processor in the x86 family, from the Pentium
onwards, or a clone thereof. Any code you write that relies on an
RDTSC instruction is inherently non-portable.
[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
Keith Thompson said:
[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
If he were capable of giving good advice, he would probably also be capable
of spelling my name correctly.
CBFalconer said:Which is what Jacob has done in lcc-win32, thus making it unusable
on any 486 system. He obviously has failed to guard its use
against the executing CPU. He can't even find the offensive code,
as of several years ago. This is a good illustration of the
penalties for using non-standardisms cavalierly.
So now, that modern CPUs are quite different from older ones, the C
standard comity is faced with a disision of to what extent, in time,
the C stndard has to be portable. Just like the 32 bit code is not
expected to run on 16 bit machine,
> why should C code written in
complience with standard XX run on a cpu predated XX.
> This does not
violate requirement that code written prior to XX standard has to run
on XX standard.
Again ill use an example of RDTSC (ReaD Time Stamp Counter):
A C call to a function tat uses RDTSC is non-portable to older cpus, i
think 586 is the 1st one that recognizes RDTSC. Now, does that mean
that C code which uses RDTSC can not conform to modern day C standard?
I think that when C99 came out RDTSC was already supported by CPUs, so
shouldn't C99 recognize code implementing RDTSC as conforming to C99
standard. If yes then why RDTSC call can not be a part of C99 standard
library.
Naturally mnemonic and opcode for RDTSC cpu instruction will be
different for different processors, but as long as compiler knows what
that opcode for a given cpu is, a compiler can compile code that uses
RDTSC to run on what ever cpu the compiler is intended for.
By the way, returning to the minimal list of cpu instructions, i thing
that thre true bare bone will have 2 instructiions, Move and Add. Move
can be used to read and write, whie add can be used to to addition,
subtraction, multiplication and division. Shift instructions would
speed it up, but are redundant. So if C is to be truly compatible
whith anything and everything, should not it limit the compiler output
to these 2 instructions. Obviously its an overkill, but gets my point
across.
Since Mac OS, Windows, Linux and Solaris all run the gcc compilerSeems like you're using an odd definition of "portable" here. On
common platforms assembly is not portable between different
compilers/assemblers on the same OS and architecture, let alone between
OSes. Certainly on a single architecture it's possible to write an
assembler that runs under many OSes, but having just one standard
assembly language even in one OS is _not_ the current state of the
world on everyday architectures--witness the x86 example I gave in the
message you replied to.
Keith Thompson said:
"Rod Pemberton" <[email protected]> writes:You should ignore any response Healthfield gives to your question.
[snip]
That's really bad advice.
If he were capable of giving good advice, he would probably also be
capable of spelling my name correctly.
Typos hppen.
Don't take it personally.
Keith said:[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
fermineutron said:Richard Heathfield wrote:
It depends what you need. But the best solution to your immediate problem -
that of performance - lies in choosing better, faster algorithms and
implementing them well. You have a great many gains to realise from doing
this; if you do it well, you may well decide that you have no need for any
assembly language after all. Implementing your current algorithms in some
assembly language or other is unlikely to result in significant performance
improvements.
Well, it seems to me that it is not so much the speed gain as a
functionality gain that can be realized from assembly language. For
example, a while back i wrote a simple C profiler, which parces C file
and inserts RDTSC statements before and after each C statement, hence
determining the number of clock cycles it took to execute that line of
code. [...]
Some compilers support __asm{ } statement which allows integration of C
and raw assembly code. A while back I asked a question about such
syntax and was told that __asm is not a part of a C standard. My
question now is:
Is there a chance that such statement will become a part of C standard
in the future? In some cases using asm language is the best way to
acomplish some small task, hence integration of C and asm would greatly
enhence C, or atleast it would in my opinion.
Is there a good reason why __asm is not a part of current C standard?
I have bumped into compilers that support and others that ignore __asm
statement so obviously it is still not a part of C standard.
CBFalconer said:Which is what Jacob has done in lcc-win32, thus making it unusable
on any 486 system. He obviously has failed to guard its use
against the executing CPU. He can't even find the offensive code,
as of several years ago. This is a good illustration of the
penalties for using non-standardisms cavalierly.
fermineutron said:This seems to develop into an optimization problem. That is, compiler
authors have to choose between limiting their code output to
instruction set of older CPUs and perhaps realizing a speed gain from
modern architecture.
For example lets consider realoc function, or more precicely the copy
portion of that function.
The most comforming way would be to move 4 bytes into EAX register from
mem1, then move 4 bytes fom EAX register to mem2, increment mem1 and
mem2 by 4, loop untill all data is copied. Probably moving 1 byte at a
time is even more conforming, since then we do not have to worry wether
the size of the data to be copied is a multiple of 4.
Now a better way for a modern system would be to use the MMX registers,
to copy data in larger chunks.
So the question becomes: should the compiler author implement method 1
or method 2?
Probably 90% of moden CPUs will accept code generated by method 2,
which is allot faster than method 1.
Some compilers will give an option to which set of cpu instruction
limit the compiler output, but not all.
So now, that modern CPUs are quite different from older ones, the C
standard comity is faced with a disision of to what extent, in time,
the C stndard has to be portable. Just like the 32 bit code is not
expected to run on 16 bit machine, why should C code written in
complience with standard XX run on a cpu predated XX. This does not
violate requirement that code written prior to XX standard has to run
on XX standard.
Again ill use an example of RDTSC (ReaD Time Stamp Counter):
A C call to a function tat uses RDTSC is non-portable to older cpus, i
think 586 is the 1st one that recognizes RDTSC. Now, does that mean
that C code which uses RDTSC can not conform to modern day C standard?
I think that when C99 came out RDTSC was already supported by CPUs, so
shouldn't C99 recognize code implementing RDTSC as conforming to C99
standard. If yes then why RDTSC call can not be a part of C99 standard
library.
Naturally mnemonic and opcode for RDTSC cpu instruction will be
different for different processors, but as long as compiler knows what
that opcode for a given cpu is, a compiler can compile code that uses
RDTSC to run on what ever cpu the compiler is intended for.
By the way, returning to the minimal list of cpu instructions, i thing
that thre true bare bone will have 2 instructiions, Move and Add. Move
can be used to read and write, whie add can be used to to addition,
subtraction, multiplication and division. Shift instructions would
speed it up, but are redundant. So if C is to be truly compatible
whith anything and everything, should not it limit the compiler output
to these 2 instructions. Obviously its an overkill, but gets my point
across.
I'd suggest you look for a tool chain that gives you this functionalityfermineutron said:Richard Heathfield wrote:
Well, it seems to me that it is not so much the speed gain as a
functionality gain that can be realized from assembly language. For
example, a while back i wrote a simple C profiler, which parces C file
and inserts RDTSC statements before and after each C statement, hence
determining the number of clock cycles it took to execute that line of
code. Now the only compiler that my profiler will work with is lcc
because the RDTSC is a part of intrinsics library of LCC, but it is not
a part of BC++ 5.02 for example. Had there been a full support for
assembly code within C I could have used inline assembly to do this and
not rely on intrinsics library of LCC.
Default User said:Keith said:[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
Pemberton is a troll.
Brian
Keith Thompson said:[snip]Rod Pemberton said:You should ignore any response Healthfield gives to your question.
That's really bad advice.
Richard Heathfield said:Keith Thompson said:
[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
If he were capable of giving good advice, he would probably also be capable
of spelling my name correctly.
Yeah, but closer to being on-topic, albeit no less wacky thanDefault User said:Keith said:[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Keith said:[snip]You should ignore any response Healthfield gives to your question.
That's really bad advice.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Pemberton is a troll.
Keith Thompson said:[snip]Rod Pemberton said:Theoretically it seems possible to develop a subset of assembly
languages which are used by motern CPUs and include in a C standard a C
library which would allow user to use the assembly subset. Since it is
a limited subset and its sintax is goverened by C it should not present
portability challenges with possible exception of older systems. any
thoughts about this?
You should ignore any response Healthfield gives to your question.
That's really bad advice.
How so? It appears that your response is incorrectly biased...
Heathfield's response was totally incorrect and borders upon incompetence.
My response was the best introduction to the minimal necessary interface to
C and various C libraries and other languages that he'll ever get. He won't
find anything even remotely close in hundreds, if not thousands, of
programming books.
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.