繁体   English   中英

编译两个asm文件时出现“ nasm:错误:指定了多个输入文件”

[英]“nasm: error: more than one input file specified” when compiling two asm files

我正在尝试使用一个包含两个asm文件的汇编语言来汇编一个小的初学者程序。 我可以制作一个文件,但是我想尝试调用另一个文件中的过程。
这是我的Makefile:

NAME        =   formatter

SRCS        =   formatter.asm clearstring.asm

OBJS        =   $(SRCS:.asm=.o)`

NASM        =   nasm
NASMFLAGS   =   -f elf64 -F dwarf

LD      =   ld

RM      =   rm -f

all:        $(NAME)

$(NAME):    $(OBJS)
    $(LD) $(OBJS) -o $(NAME)

#(1):
# formatter.o:  formatter.asm
#   $(NASM) -o formatter.o formatter.asm $(NASMFLAGS)
# clearstring.o:    clearstring.asm
#   $(NASM) -o clearstring.o clearstring.asm $(NASMFLAGS)

#(2):
$(OBJS):    $(SRCS)
    $(NASM) -o $(OBJS) $(SRCS) $(NASMFLAGS)

使用注释(1)下的代码时,一切正常,但是当我使用紧凑代码(2)时, make给我以下信息:

nasm -o formatter.o clearstring.o formatter.asm clearstring.asm -f elf64 -F dwarf
nasm: error: more than one input file specified
nasm: error: more than one input file specified
type `nasm -h' for help
make: *** [formatter.o] Error 1

我知道组装步骤不正确,但我无法做到:

nasm -o formatter.o formatter.asm -f elf64 -F dwarf
nasm -o clearstring.o clearstring.asm -f elf64 -F dwarf

我希望我对这个网站的第一个问题已经足够清楚了。
你能帮我么 ?

这样的规则应该可以解决问题:

%.o: %.asm
    $(NASM) $(NASMFLAGS) -o $@ $<

$@$<将分别扩展为目标和(第一个,在本例中,仅是)输入文件的名称。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM