编译简单程序集时出错
Error in compiling a simple assembly
我正在学习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
我该如何解决这个问题?
ptr
是 NASM 中未定义的关键字。只需删除它(在第 6 行),您的代码就会编译:
movsx ecx, word [eax]
我正在学习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
我该如何解决这个问题?
ptr
是 NASM 中未定义的关键字。只需删除它(在第 6 行),您的代码就会编译:
movsx ecx, word [eax]