1

hello_world.c

#include <stdio.h>
int main()
{
    printf("Hello World\n");
    return 0;
}

Running gcc hello_world.c -S generates a hello_world.s file in assembly language.

hello_world.s

    .file   "hello_world.c"
    .section    .rodata
.LC0:
    .string "Hello World"
    .text
    .globl  main
    .type   main, @function
main:
.LFB0:
    .cfi_startproc
    pushq   %rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    movq    %rsp, %rbp
    .cfi_def_cfa_register 6
    movl    $.LC0, %edi
    call    puts
    movl    $0, %eax
    popq    %rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3"
    .section    .note.GNU-stack,"",@progbits

Is there some way to find out in what type of assembly language the code was generated in (besides knowing the syntax of all assembly languages.)?

Reference for myself or anyone else who didn't know this:

To get your processor architecture run the following:

uname -p

Community
  • 1
  • 1
Bentley4
  • 10,678
  • 25
  • 83
  • 134

1 Answers1

2

It is the AT&T syntax for the GNU assembler of the target code's CPU by default. There are options to alter that.

wallyk
  • 56,922
  • 16
  • 83
  • 148
  • I don't understand. I thought computers with different CPU architectures used different types of assembly languages. How can they all use AT&T syntax? Or do you mean that the gcc command always generates AT&T syntax regardless of your architecture? – Bentley4 Jun 06 '14 at 01:04
  • 2
    An assembled file is in binary. An assembly file is text. The AT&T syntax describes the way the assembly file is written, it's architecture independent. The actual instructions in the assembly file are what differs from arch to arch. – Happington Jun 06 '14 at 01:14