我正在使用 nasm 来组装我的xyz.asm
文件以xyz.obj
使用命令:
nasm -f win32 xyz.asm
使用链接它alink
会产生重定位错误。
请帮我解决这个问题。
我正在使用 nasm 来组装我的xyz.asm
文件以xyz.obj
使用命令:
nasm -f win32 xyz.asm
使用链接它alink
会产生重定位错误。
请帮我解决这个问题。
不幸的是,我不能给你“经过测试”的代码来在 Windows 中调用你的 gcd 示例(不会做 Windows)。它可能看起来有点像这样,但这可能还不够接近实际工作。
; nasm -f win32 callgcd.asm
; alink -oPE -entry _main callgcd.obj gcdi.obj win32.lib
global _main
extern _scanf
extern _printf
extern ExitProcess
extern xyz ; that's what you called it
section .data
fmt db "%i", 0
section .bss
number1 resd 1
number2 resd 1
section .text
_main:
push number1
push fmt
call _scanf
add esp 4 * 2
push number2
push fmt
call _scanf
add esp, 4 * 2
push dword [number1]
push dword [number2]
call xyz
add esp, 4 * 2
push eax
push fmt
call _printf
add esp, 4 * 2
push 0
call ExitProcess
也许一些 Windows 用户可以给你更好的东西。
首先告诉 nasm 你想要 .obj 文件。之后alink应该可以正常工作
nasm -f win32 xyz.asm -o xyz.o or -o xyz.obj
希望这可以帮助。