2017-01-07 27 views
-1

我学习ASM和现在看到了一个剧本,但我不能编译:错误编译一个简单的组装

section .text 
    global _start  ;must be declared for using gcc 
_start:      ;tell linker entry point 
    mov  edx, [ebp+input_file] 
    mov  eax, [edx+8] 
    movsx ecx, word ptr [eax] 
    push ecx 
    mov  edx, [ebp+input_file] 
    mov  eax, [edx+8] 
    push eax 
    mov  ecx, [ebp+var_8] 
    mov  edx, [ecx+2748h] 
    push edx 
    call memcpy 
    int  0x80  ;call kernel 
    mov  eax, 1  ;system call number (sys_exit) 
    int  0x80  ;call kernel 

section .data 

当我使用编译此代码:

nasm -f elf *.asm; ld -m elf_i386 -s -o demo *.o 

我得到这个结果:

Error: comma, colon, decorator or end of line expected after operand >
ld: cannot find *.o: No such file or directory

我该如何解决这个问题?

+2

您确定没有该错误消息的行号?这将有助于更长时间的来源标记线路,这是造成问题的原因。 – Ped7g

+0

正是它是我试图把它放在一个简单的hello世界脚本中的一段代码。现在我看到input_file,var_8是未定义的@Ped7g – reza

回答

1

ptr是NASM中未定义的关键词。只要将其删除(在第6行),您的代码将被编译:

movsx ecx, word [eax]