0
votes

Below is a gcc command line string I used to output to assembly language listing using -masm=intel. Both command line strings work, but they both produce AT&T syntax, not Intel syntax.

gcc -S -masm=intel Svx.c

but that produces a mixed Intel and AT&T syntax.

      .file "Svx.c"
    .intel_syntax noprefix
    .text
    .globl  main
        .type   main, @function
    main:
.LFB0:
        .cfi_startproc
    push    rbp
    .cfi_def_cfa_offset 16
    .cfi_offset 6, -16
    mov rbp, rsp
    .cfi_def_cfa_register 6
    mov DWORD PTR -4[rbp], 0
    jmp .L2
.L3:
    add DWORD PTR -4[rbp], 1
.L2:
    cmp DWORD PTR -4[rbp], 1000000000
    jne .L3
    mov eax, DWORD PTR -4[rbp]
    pop rbp
    .cfi_def_cfa 7, 8
    ret
    .cfi_endproc
.LFE0:
    .size   main, .-main
    .ident  "GCC: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0"
    .section    .note.GNU-stack,"",@progbits

The output looks like a modified Intel syntax, but the AT&T-specific cfi directives for stack handling are not translated. And add DWORD PTR -4[rbp],1 is not Intel syntax.

Why do I get mixed AT&T and Intel syntax with -masm=intel?

1
AT&T syntax uses a %. For example xorq %rax, %rax or pop %rbpnissim abehcera
@nissimabehcera Not for GNU directives mate (example). It's a bit like macros in C. Not an actual part of the assembly language (whose dialect you control; Intel vs AT&T) but instructions to the assembler itself.Lightness Races in Orbit
@Lightness Races in Orbit You're right but I'm talking about a instructions not about directives.nissim abehcera
@nissimabehcera The question is (mostly) asking about the directives. That's the point!Lightness Races in Orbit
"And add DWORD PTR - 4[rbp],1 is not Intel syntax"nissim abehcera

1 Answers

2
votes

The CFI directives are directives for the GNU assembler. In general, such directives (which begin with a .) have nothing to do with which assembler dialect you've chosen, and as such the lines you're worried about are not "AT&T specific" nor indeed even related to AT&T.

And add DWORD PTR -4[rbp],1 is Intel syntax.