我正在研究纳斯(保罗·卡特的书 - PC汇编语言)
first.asm
1 ; file: first.asm
2 ; First assembly program. This program asks for two integers as
3 ; input and prints out their sum.
4 ;
5 ; To create executable using djgpp:
6 ; nasm -f coff first.asm
7 ; gcc -o first first.o driver.c asm_io.o
书让我以这种方式工作。
但它没有用。
C:\temp>gcc -o first first.o driver.c asm_io.o
c:/win-builds64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64
-mingw32/bin/ld.exe: i386 architecture of input file `first.o' is incompatible w
ith i386:x86-64 output
c:/win-builds64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64
-mingw32/bin/ld.exe: i386 architecture of input file `asm_io.o' is incompatible
with i386:x86-64 output
first.o:first.asm:(.text+0xb): undefined reference to `print_string'
first.o:first.asm:(.text+0x10): undefined reference to `read_int'
c:/win-builds64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64
-mingw32/bin/ld.exe: first.o: bad reloc address 0x10 in section `.text'
c:/win-builds64/bin/../lib64/gcc/x86_64-w64-mingw32/4.8.3/../../../../x86_64-w64
-mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
这是错误代码。
我认为有两个问题之一。
请帮帮我。
抱歉,我不会说英语。答案 0 :(得分:0)
您需要Carter's Example Code for Cygwin and Mingw32。对于您的第一个程序,您需要使用以下程序:
cdecl.h
driver.c
first.asm
asm_io.inc
asm_io.o
使用
构建first.exe
nasm.exe -fwin32 first.asm
gcc.exe -m32 -o first.exe asm_io.o driver.c first.obj