C
clusardi2k
Years ago, someone told me once that C is assembly language. Is this true. Do you have any proof why or why not.
Thanks,
Thanks,
Years ago, someone told me once that C is assembly language. Is this
true. Do you have any proof why or why not.
Years ago, someone told me once that C is assembly language. Is this
true. Do you have any proof why or why not.
Years ago, someone told me once that C is assembly language. Is this true. Do you have any proof why or why not.
James Kuyper said:The answer to this depends upon what you mean by "assembly language".
Wiktionary says "(computing) A programming language in which the source
code of programs is composed of mnemonic instructions, each of which
corresponds directly to a machine instruction for a particular processor."
This definition is completely consistent with every use I'd ever seen of
the term until quite recently, including all three assembly languages
I've programmed in. It does not fit C at all. C is not oriented to a
particular processor, and does not specify the machine instructions to
be generate. It only specifies what the machine instructions must do; it
is perfectly legal for a C compiler to generate any sequence of machine
instructions that produces the specified result, and what the C standard
fails to mandate allows a great many alternative ways of translating any
particular C program into machine instructions.
However, the last time I ever programmed in assembly language was two
decades ago. I've recently been informed that the distinction between
modern assembly languages and higher level languages has become so fuzzy
as to have pretty much completely disappeared. The person who said this
claimed that modern assembly languages no longer implement a one-to-one
relationship between assembly language instructions and machine language
instructions, but are free to choose from a wide variety of possible
translations. Also, he claimed that modern assembly languages are no
longer restricted to a particular processor, that the same assembly code
can be used to generate different machine code on different platforms,
even if they have significantly different architectures. On the basis of
that claim, he asserted that, since the same was true of C, C could
therefore be classified as an assembly language. To me, it would seem
more reasonable to say that the languages he described (if he was
describing them correctly) were now high level languages, and no longer
assembly languages.
The answer to this depends upon what you mean by "assembly language".
Wiktionary says "(computing) A programming language in which the
source code of programs is composed of mnemonic instructions,
each of which corresponds directly to a machine instruction for a
particular processor."
This definition is completely consistent with every use I'd ever seen of
the term until quite recently, including all three assembly languages
I've programmed in. It does not fit C at all. C is not oriented to a
particular processor, and does not specify the machine instructions to
be generate. It only specifies what the machine instructions must do; it
is perfectly legal for a C compiler to generate any sequence of machine
instructions that produces the specified result, and what the C standard
fails to mandate allows a great many alternative ways of translating any
particular C program into machine instructions.
However, the last time I ever programmed in assembly language was two
decades ago. I've recently been informed that the distinction between
modern assembly languages and higher level languages has become so fuzzy
as to have pretty much completely disappeared. The person who said this
claimed that modern assembly languages no longer implement a one-to-one
relationship between assembly language instructions and machine language
instructions, but are free to choose from a wide variety of possible
translations. Also, he claimed that modern assembly languages are no
longer restricted to a particular processor, that the same assembly code
can be used to generate different machine code on different platforms,
even if they have significantly different architectures. On the basis of
that claim, he asserted that, since the same was true of C, C could
therefore be classified as an assembly language. To me, it would seem
more reasonable to say that the languages he described (if he was
describing them correctly) were now high level languages, and no longer
assembly languages.
So trying to sum all this up, the question of whether or not C is an
assembly language is currently no!
Am I correct in my "no" assumption, or is it a more appropriate answer to
say yet to be determined via a mutually agreed apon definition.
I remember that discussion, but not all the details of it. As I
recall, the person making that claim, when repeatedly pressed for
concrete examples, backed away from it.
James Kuyper said:On 04/02/2013 09:06 PM, Keith Thompson wrote:
That discussion was so fresh in my memory that I was surprised to find
it occurred nearly two years ago. "He" was Rui Maciel, and the thread
Subject: was "for your languages". Rui never backed down from his claim,
he just failed to respond to requests for concrete examples.
My own understanding is that the purpose of an assembly language is to
provide a convenient mechanism for specifying the precise sequence of
machine language instructions to be generated, which is therefore
inherently platform dependent.
Macros are merely a convenient way of
packaging specification of a large number of instructions into one
piece. An assembler that produces a different sequence of machine
instructions from the one specified, is defective. Assembly code
intended for one platform cannot be usefully ported to a radically
different platform, precisely because, by "radically different", I mean
a platform for which a wildly different sequence of machine code
instructions would be needed to generate the same desired behavior.
One of the key purposes for higher level languages like C is to avoid
having to specify the precise sequence of machine language instructions.
Instead, C code specifies only the desired behavior, and leaves it up
to the implementation to decide which machine language instructions to
generate. The same C code can be used to generate many different
sequences of machine code, without rendering the implementation
non-conforming, so long as all of those sequences implement the
specified behavior. C compilers for wildly different platforms will
produce wildly different sequences of machine language instructions,
that implement the same behavior - producing that result is precisely
one of the purposes for designing higher level languages like C.
Rui claimed (but never provided a concrete example) that in modern
usage, "macro assembly language" is used to refer to things that I would
call a "high level language", and that things that I would consider it
proper to call "assembly languages" had become obsolete so long ago that
had never existed during his career.
He pointed out that typical C
implementations deterministically generate specific sequences of machine
language instructions when given a specific C program as input, and
therefore concluded it was appropriate to call C an assembly language,
despite the fact that different C compilers had different deterministic
mappings, without ceasing to be conforming. Also, the determinism of the
process was merely a convenience, and is not required of a conforming
implementation of C - that didn't faze him, either.
So trying to sum all this up, the question of whether or not C
is an assembly language is currently no!
Am I correct in my "no" assumption, or is it a more appropriate
answer to say yet to be determined via a mutually agreed apon
definition.
Is this question just an academic one.
I would say so, but mostly in the same sense that, in Calculus
when you do a limit you get closer and closer but never actually
get there. There are very few things that need to be done, and can't
be done in C, but there are still some.
Now, interestingly, as I understand it in some of the IBM mainframe
systems there are things that can be done in C, but not in assembler.
Not related to machine instructions, but in information passed onto
the linker.
It might be that for some machines that it is easier to write the C
compiler than the assembler. Or, as above, features are added earlier
to a C compiler than to an assembler. If that happens often enough,
then the answer in some cases could be yes.
Ah, der neueste und bis heute genialste Streich unsere gro?enZumindest nicht ?ffentlich!
So trying to sum all this up, the question of whether or not C is an
assembly language is currently no!
Am I correct in my "no" assumption, or is it a more appropriate answer
to say yet to be determined via a mutually agreed apon definition.
Is this question just an academic one.
glen said:I would say so, but mostly in the same sense that, in Calculus
when you do a limit you get closer and closer but never actually
get there. There are very few things that need to be done, and can't
be done in C, but there are still some.
Now, interestingly, as I understand it in some of the IBM mainframe
systems there are things that can be done in C, but not in assembler.
Not related to machine instructions, but in information passed onto
the linker.
Yes, but why do you want to do that? ...
... Years (decades) ago it was for
speed or size (or both), but those reasons are now long gone for
most systems. Maybe still true for some embedded systems, though.
James Kuyper said:On 04/02/2013 09:06 PM, Keith Thompson wrote:
...
That discussion was so fresh in my memory that I was surprised to find
it occurred nearly two years ago. "He" was Rui Maciel, and the thread
Subject: was "for your languages". Rui never backed down from his claim,
he just failed to respond to requests for concrete examples.
glen herrmannsfeldt said:Yes, but why do you want to do that? Years (decades) ago it was for
speed or size (or both), but those reasons are now long gone for
most systems. Maybe still true for some embedded systems, though.
glen herrmannsfeldt said:I would say so, but mostly in the same sense that, in Calculus
when you do a limit you get closer and closer but never actually
get there. There are very few things that need to be done, and can't
be done in C, but there are still some.
Now, interestingly, as I understand it in some of the IBM mainframe
systems there are things that can be done in C, but not in assembler.
Not related to machine instructions, but in information passed onto
the linker.
It might be that for some machines that it is easier to write the C
compiler than the assembler. Or, as above, features are added earlier
to a C compiler than to an assembler. If that happens often enough,
then the answer in some cases could be yes.
Other reasons, which you might also dismiss as "long gone", include
wanting to access hardware features for which the higher level language
you would otherwise want to use doesn't provide a hook. When a higher
level language does provide such a hook, it's often implemented in
assembly language (or at least, that was true back when I did write
assembly language), so it's still assembly language in the end.
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.