Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #5198

Re: for your languages

From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: for your languages
Date 2011-06-01 09:07 -0700
Organization None to speak of
Message-ID <lnhb89mt66.fsf@nuthaus.mib.org> (permalink)
References (5 earlier) <4de42bc3$0$16784$a729d347@news.telepac.pt> <specification-20110531040559@ram.dialup.fu-berlin.de> <4de520c6$0$16777$a729d347@news.telepac.pt> <lnd3iyofu2.fsf@nuthaus.mib.org> <4de64db9$0$16783$a729d347@news.telepac.pt>

Show all headers | View raw


Rui Maciel <rui.maciel@gmail.com> writes:
> Keith Thompson wrote:
>> Rui Maciel <rui.maciel@gmail.com> writes:
>>> Stefan Ram wrote:
>>>> ISO/IEC 9899:1999 (E) does nowhere specify that this code
>>>> has to be generated. Any other code that behaves /as-if/
>>>> is as well, like »fputs( "hello, world", stdout )«.
>>>> 
>>>> A macro assembler allows you to /enforce/ a specific
>>>> machine instruction.
>>>
>>> In this case it's irrelevant what the C standard specifies and doesn't
>>> specify.
>> 
>> It's entirely relevant to the point most of us are trying to discuss.
>
> The issue being discussed is that all high level programming languages are 
> macro-assembly languages of sorts.  No one is arguing that all languages 
> employ the same level of abstraction.  Therefore, the level of abstraction 
> provided by the C programming language, and how it compares with other 
> languages, is irrelevant.  
>
> Adding to this, I'm not aware of a single assembly language which 
> "enforces" specific machine instructions.  Assembly languages may provide 
> the user with a way to state what opcode they wish to use and where they 
> wish to use it.  Yet, nothing forces a compiler to obey that request, and 
> any compiler writer is free to add some form of optimization that is able 
> to generate a completely different set of opcodes.  This applies to all 
> languages, including any assembly language and C.

Then things must have changed a lot more than I was aware of.  In my
experience (which admittedly is fairly old), *all* assembly languages
specify exactly which machine instructions are to be generated; that's
the whole point of an assembly language.

Here's a small assembly language program (it's gcc's output for a
"hello, world" C program):

        .file   "hello.c"
        .section        .rodata
.LC0:
        .string "Hello, world"
        .text
.globl main
        .type   main, @function
main:
        pushl   %ebp
        movl    %esp, %ebp
        andl    $-16, %esp
        subl    $16, %esp
        movl    $.LC0, (%esp)
        call    puts
        movl    $0, %eax
        leave
        ret
        .size   main, .-main
        .ident  "GCC: (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2"
        .section        .note.GNU-stack,"",@progbits

If I ran that through an assembler and got something other than
a pushl instruction, followed by a movl instruction, followed by
an andl instruction, etc., I would conclude either that I'm using
a broken assembler, or that I'm using something that's more than
just an assembler.

>>>           For example, are you aware of any standard on any assembly
>>> language which specifies which code has to be generated from any given
>>> instruction?
>> 
>> It's been a long time, but I thought that was the whole point of
>> assembly language: it specifies the machine language instructions
>> to be generated.  Has the meaning of the term changed that much?
>> If so, what does it mean now?
>
> No one is arguing that assembly languages employ a lower level of 
> abstraction.  Yet, this doesn't change their fundamental nature as a 
> programming language, nor does it mean that their nature is any different 
> than other programming languages, such as C.  In any case we are dealing 
> with languages which let the programmer specify sequences of instructions.  
> The language doesn't change with the way a particular compiler maps those 
> instruction sequences to sets of opcodes.

Was that intended to be an answer to my question?  I wasn't asking about
levels of absraction.  My question was much more specific.

The way I've always understood the terms are as follows.

A program in an assembly language specifies, more or less exactly,
the sequence of CPU instructions to be generated.  An assembler's
job is to translate the assembly language input to machine code.
Macro assemblers make it possible for a single line of assembly
language to specify multiple CPU instructions, but the input still
specifies what machine instructions are to be generated.

My system (an x86 Linux system) has an assembler, /usr/bin/as, which
is the GNU assembler.  It's used primarily as a backend to various
compilers.  As far as I know, it behaves as I've described above.

(A program that reads assembly language input and performs some
optimizations before generating the final machine code is certainly
possible.  I'd such a program isn't a *pure* assembler, but you
could call it an "optimizing assembler".)

A program in a higher-level, non-assembly language such as C
typically doesn't specify *any* machine instructions.  Rather,
it specifies the run-time behavior of the program.  A language or
dialect might have features, such as machine-code insertions or
directives, that specify things other than that, but the main point
of the program is to specify behavior.  The translator for such a
language, typically called a "compiler" generates assembly or machine
code whose behavior satisfies the input program's specification.

That's the difference between an assembly language and a compiled
language: the former specifies CPU instructions, and the latter
specifies behavior.  In both cases, the output consists of CPU
instructions, and those instruction implement some behavior.
The difference is in how the languages are defined.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

for your languages "io_x" <a@b.c.invalid> - 2011-05-28 09:08 +0200
  Re: for your languages BGB <cr88192@hotmail.com> - 2011-05-28 02:48 -0700
    Re: for your languages "io_x" <a@b.c.invalid> - 2011-05-29 17:51 +0200
      Re: for your languages Nick Keighley <nick_keighley_nospam@hotmail.com> - 2011-06-16 15:39 -0700
        Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-17 09:55 +0200
          Re: for your languages Shao Miller <sha0.miller@gmail.com> - 2011-06-19 22:21 -0500
            Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-20 09:51 +0200
              Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-20 12:06 +0200
              Re: for your languages Shao Miller <sha0.miller@gmail.com> - 2011-06-20 10:08 -0500
                Re: for your languages "io_x" <a@b.c.invalid> - 2011-07-08 20:06 +0200
  Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-28 11:06 +0100
    Re: for your languages BGB <cr88192@hotmail.com> - 2011-05-28 03:38 -0700
    Re: for your languages "BartC" <bc@freeuk.com> - 2011-05-28 16:01 +0100
      Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-28 19:36 +0100
        Re: for your languages "BartC" <bc@freeuk.com> - 2011-05-28 21:18 +0100
          Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-29 12:33 +0100
            Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-05-29 08:31 -0400
              Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-05-29 05:37 -0700
                Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-05-29 09:09 -0400
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-05-29 07:00 -0700
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-05-29 16:52 +0100
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 02:18 +0100
                Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-05-30 22:21 -0400
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-05-30 20:39 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-29 12:44 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 02:12 +0100
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 10:44 -0700
              Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 02:05 +0100
            Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-29 12:34 -0700
              Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 02:00 +0100
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-05-31 13:10 +0100
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-05-31 06:20 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 11:53 -0700
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-05-31 12:23 +0000
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 17:46 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-05-31 17:05 +0000
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-01 15:39 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-06-01 17:53 +0000
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-02 22:18 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-06-03 00:44 +0000
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-05-31 19:04 +0000
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-01 15:44 +0100
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-06-01 19:40 +0000
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-02 21:58 +0100
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-06-02 23:09 +0000
                Re: for your languages Shao Miller <sha0.miller@gmail.com> - 2011-06-02 21:28 -0500
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 10:41 -0700
    Re: for your languages Uncle Steve <stevet810@gmail.com> - 2011-05-28 11:15 -0400
      Re: for your languages Lorenzo Villari <vlllnz@tiscali.it> - 2011-05-28 20:05 +0200
        Re: for your languages Uncle Steve <stevet810@gmail.com> - 2011-05-28 14:16 -0400
    Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-28 12:07 -0700
      Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-29 12:19 +0100
        Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-05-29 08:59 -0400
          Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 01:50 +0100
        Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-05-29 20:36 +0000
          Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 00:28 +0100
            Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-05-30 17:21 -0700
              Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 01:58 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-05-31 01:27 +0000
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 10:37 -0700
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-05-31 18:34 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-01 15:06 +0100
                Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-06-01 10:30 -0400
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-02 21:36 +0100
                Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-06-02 22:06 -0400
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-01 18:19 -0700
                Re: for your languages Shao Miller <sha0.miller@gmail.com> - 2011-06-02 01:06 -0500
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-03 12:02 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-02 21:34 +0100
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-02 15:53 -0700
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-03 12:24 -0700
            Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-05-31 01:10 +0000
            Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 10:34 -0700
              Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-01 14:58 +0100
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-02 21:18 +0100
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-02 13:40 -0700
                Re: for your languages Billy Mays <noway@nohow.com> - 2011-06-02 17:31 -0400
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-03 10:39 -0700
                Re: for your languages James Kuyper <jameskuyper@verizon.net> - 2011-06-02 22:19 -0400
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-02 19:36 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-03 08:44 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-04 14:41 +0100
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-06-04 16:31 +0000
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-04 09:51 -0700
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-06-05 00:05 +0000
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-04 18:31 -0700
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-04 10:02 -0700
                Re: for your languages cri@tiac.net (Richard Harter) - 2011-06-04 22:10 +0000
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-04 18:26 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-05 13:40 +0100
                Re: for your languages Angel <angel+news@spamcop.net> - 2011-06-05 15:47 +0000
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-05 10:16 -0700
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-05 10:30 -0700
                Re: for your languages Heikki Kallasjoki <see@end.of.message.invalid> - 2011-06-05 17:38 +0000
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-05 10:49 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-04 09:50 -0700
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-04 13:23 -0700
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-05 12:32 +0100
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-05 07:15 -0700
                Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-06 18:18 +0200
                Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-06-06 11:40 -0700
                Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-07 16:57 +0200
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-07 08:36 -0700
                Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-07 18:19 +0200
                Re: for your languages "io_x" <a@b.c.invalid> - 2011-06-07 18:32 +0200
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-05 12:33 -0700
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-05 13:08 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-05 13:54 -0700
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-05 18:57 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-05 20:37 -0700
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-05 20:58 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-05 21:49 -0700
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-05 22:05 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-06 09:11 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-16 13:00 -0700
                Re: for your languages Michael Press <rubrum@pacbell.net> - 2011-06-06 02:04 -0700
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-06-06 10:21 +0100
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-06-05 22:47 +0100
                Re: for your languages China Blue Angels <chine.bleu@yahoo.com> - 2011-06-05 18:25 -0700
                Re: for your languages Ian Collins <ian-news@hotmail.com> - 2011-06-06 13:41 +1200
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-06-06 10:06 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-06-06 15:39 +0000
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-06-06 15:39 +0000
        Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 00:44 +0100
          Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-05-31 18:09 +0100
            Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-31 12:00 -0700
              Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-01 15:33 +0100
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-01 09:07 -0700
                Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-06-01 10:12 -0700
                Re: for your languages BGB <cr88192@hotmail.com> - 2011-06-01 12:45 -0700
                Re: for your languages "BartC" <bc@freeuk.com> - 2011-06-03 15:41 +0100
                Re: for your languages Rui Maciel <rui.maciel@gmail.com> - 2011-06-05 13:30 +0100
                Re: for your languages Seebs <usenet-nospam@seebs.net> - 2011-06-06 15:39 +0000
  Re: for your languages "Kleuskes & Moos" <kleuske@xs4all.nl> - 2011-05-28 03:34 -0700
    Re: for your languages "io_x" <a@b.c.invalid> - 2011-05-29 08:42 +0200
  Re: for your languages Anders Wegge Keller <wegge@wegge.dk> - 2011-05-29 01:00 +0200
    Re: for your languages Angel <angel+news@spamcop.net> - 2011-05-28 23:49 +0000
      Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-28 18:42 -0700
    Re: for your languages Keith Thompson <kst-u@mib.org> - 2011-05-28 18:42 -0700

csiph-web