Reputation: 167
I've created in windows c++ project in Visual Studio to learn how to write asm functions. So in my project I've got hello.asm with this simple code:
.686
.MODEL FLAT
.STACK
.DATA
.CODE
hello PROC
xor eax,eax
ret
hello ENDP
END
and asm_test.cpp with main function like this:
#include "stdafx.h"
#include <Windows.h>
extern "C" void hello();
int _tmain(int argc, _TCHAR* argv[])
{
hello();
return 0;
}
So in general ml.exe doesnt have any problem compiling asm file to hello.obj but hello() function doesnt' know where should it be taken from. And here is what compiler tells me.
1>------ Построение начато: проект: asm_test, Конфигурация: Debug Win32 ------
1> Assembling hello.asm...
1>asm_test.obj : error LNK2019: ссылка на неразрешенный внешний символ _hello в функции _wmain
1>G:\renderer\asm_test\Debug\asm_test.exe : fatal error LNK1120: неразрешенных внешних элементов: 1
========== Построение: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========
Sorry, it's on russion, but it's clear that it can not find hello function
Upvotes: 0
Views: 2686
Reputation: 2151
change hello
to be _hello
plz. for your hello.asm
, it should be:
.686
.MODEL FLAT
.STACK
.DATA
.CODE
_hello PROC
xor eax,eax
ret
_hello ENDP
END
Upvotes: 1