Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/assembly/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ubuntu 如何在nasm上运行此汇编代码?_Ubuntu_Assembly_Makefile_X86_Nasm - Fatal编程技术网

Ubuntu 如何在nasm上运行此汇编代码?

Ubuntu 如何在nasm上运行此汇编代码?,ubuntu,assembly,makefile,x86,nasm,Ubuntu,Assembly,Makefile,X86,Nasm,我有一个游戏源代码,但我无法在nasm上组装它,我不明白问题出在哪里 以下是生成文件: # Makefile for the nibbles game. all: nibbles_asm nibbles_asm_start # Rule for compiling C source .c.o: gcc -Os -march=i686 -Wall -g -c $< # Rule for compiling assembly source .S.o: as -gstabs

我有一个游戏源代码,但我无法在nasm上组装它,我不明白问题出在哪里

以下是生成文件:

# Makefile for the nibbles game.

all: nibbles_asm nibbles_asm_start

# Rule for compiling C source
.c.o:
    gcc -Os -march=i686 -Wall -g -c $<

# Rule for compiling assembly source
.S.o:
    as -gstabs $^ -o $@



# ASM game
nibbles_asm: main.o nibbles.o helpers.o
    gcc -lcurses $^ -o -V $@

# ASM game
nibbles_asm_start: start.o nibbles.o helpers.o workaround.o
    gcc -lcurses -lc -nostdlib $^ -o $@

clean:
    rm -f *~
    rm -f *.o
    rm -f nibbles nibbles_asm
似乎as-gstabs$^-o$@不构建nibbles\u asm文件!
我自己也在终端中键入了命令,但它给了我很多错误。我的朋友在他的计算机上运行此代码,因此代码没有任何问题。

nibbles.S
nibbles.o
没有依赖关系。另外,
helpers.o
workaround.o
没有关联的源文件关系。添加这些关系,它应该会工作。

您的gcc命令中有一个错误的
-V
(作为
-o
的参数)。将其移除或放在开头


您的第二个错误
尝试执行'i686 linux gnu gcc--lcurses':没有这样的文件
意味着您在gcc和-lcurses之间的某个地方缺少一个空格。

迂腐的备注:您不能在nasm上运行汇编。你在CPU上运行它。你用NASMW组装它,
-V
到底是为了什么?如果没有-V,它会出现以下错误:main.o:In function
main':/home/aida/Desktop/13/main.c:45:start\u game的引用未定义,有人告诉我在
-o
应该是一个文件名之后把它放在这里来修复。如果需要
-V
,请将其移到其他位置,而不是在选项和选项值之间。我将-V移到了这里:gcc-V-lcurses$^-o$@并且它没有构建半字节asm,但至少可以构建半字节asm\u start,请帮助解释为什么会这样?!整个汇编代码未汇编!:(实际上,这些关系存在,$^表示main.o nibbles.o helpers.o和$@=nibbles\u asm
nibbles\u asm
似乎是可执行文件。请注意,这是Linux。我将as-gstabs$^-o$@更改为as-gstabs main.o nibbles.o helpers.o nibbles\u asm,然后再次出现相同的错误!
as   -o nibbles.o nibbles.s
gcc -lcurses main.o nibbles.o helpers.o -o -V nibbles_asm
gcc: nibbles_asm: No such file or directory
make: *** [nibbles_asm] Error 1