2012-04-09 3 views
0

(それはNASMで動作するように)私はこれはどのようなスタイルアセンブリですか(intel、att ... etc?)、どうすればそれを生成できますか?

;hello.asm 
[SECTION .text] 

global _start 


_start: 

    jmp short ender 

    starter: 

    xor eax, eax ;clean up the registers 
    xor ebx, ebx 
    xor edx, edx 
    xor ecx, ecx 

    mov al, 4  ;syscall write 
    mov bl, 1  ;stdout is 1 
    pop ecx   ;get the address of the string from the stack 
    mov dl, 5  ;length of the string 
    int 0x80 

    xor eax, eax 
    mov al, 1  ;exit the shellcode 
    xor ebx,ebx 
    int 0x80 

    ender: 
    call starter ;put the address of the string on the stack 
    db 'hello' 

まず、このようなアセンブリコードを生成するためにオフにしようとしている、どのようなアセンブリスタイルはこれです第二に、どのように私は、コマンドを使用して、Cファイルからそれを生成することができますgcc -S code.c -o code.S -masm=intel

+0

'-masm = intel'はこのスタイルを生成するものです(デフォルトのAT&T構文ではなくIntel構文)。しかし、それは実際の指示だけを支配します。 '[SECTION]'のようなものはNASM固有であり、GCCは常にGAS固有のものを生成します。 –

+0

それでは(-masm = intel)で上記のコマンドを実行した後、 'nasm -f elf code.S'コマンドを実行しようとするとエラーが発生します。 – Nosrettap

+1

ガスがガスではないので。指示は間違っています。 –

答えて

1

これはIntelスタイルです。

あなたが質問に書いたコマンドラインの何が問題なのですか?

+0

私はそのコマンドを使用すると、 'nasm -f elf code.S'コマンドを使用しようとします。 – Nosrettap

関連する問題