2

Windows 7 (NASM を使用) で次のコードをコンパイルしようとしています。

[BITS 32]

extern ExitProcess
import ExitProcess kernel32.dll
extern MessageBoxA
import MessageBoxA user32.dll

segment .data use32
Caption db 'Caption Text',0
Text db "My MessageBox Text.",0

segment .code use32
..start:
push dword 0
push dword Caption
push dword Text
push dword 0
call [MessageBoxA]

push dword 0
call [ExitProcess]

これをコンパイルするために、試してみnasm -o test.o test.asmましたが、次のように表示されます。

test.asm:4: error: parser: instruction expected
test.asm:6: error: symbol `import' redefined
test.asm:6: error: parser: instruction expected

うまくいかないのはなぜですか?

編集:わかりました。単純な間違い...nasm -o test.o -f obj test.asmうまくいく...

4

2 に答える 2

3

既知の問題のようです。http://cboard.cprogramming.com/windows-programming/114989-nasm-import-directive-failing-expected-instruction-error.htmlで提案されている解決策

于 2013-02-15T20:53:59.720 に答える