2012-04-09 63 views
0

我想产生这样的汇编代码(以便它NASM作品)这是什么风格的装配(intel,att ...等),我该如何制作它?

;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'正是产生这种风格(Intel语法,而不是默认的AT&T语法)的原因。但是,只管理实际的说明。像[[SECTION]]这样的东西是NASM特有的,GCC总是生成特定于GAS的。 – 2012-04-09 07:14:26

+0

然后,当我运行上面的命令(-masm = intel),然后尝试运行命令'nasm -f elf code.S'时,我怎么会遇到一些错误? – Nosrettap 2012-04-09 07:16:14

+1

因为nasm不是气体。指令是错误的。 – 2012-04-09 07:27:13

回答

1

这是英特尔风格。

你在问题中编写的命令行有什么问题?

+0

这只是,如果我使用该命令,然后我尝试使用命令'nasm -f elf code.S'我得到了一大堆错误 – Nosrettap 2012-04-09 07:16:52

相关问题