My asm file
.386
.model flat,c
;----------------------------------------------
; Reference the variables from the cpp file
;----------------------------------------------
extern global_char:byte
extern global_short:word
extern global_int:dword
extern global_ll:qword
.code
IntegerAddition proc
push ebp
mov ebp, esp
; Compute += global_char
mov al, [ebp+8]
add [global_char], al
; Compute += global_short
mov ax, [ebp+12]
add [global_short], ax
; Compute += global_int
mov eax, [ebp+16]
add [global_int], eax
; Compute += globall
mov eax, [ebp+20]
mov edx, [ebp+24]
add dword ptr[global_ll], eax
adc dword ptr[global_ll], edx
pop ebp
ret
IntegerAddition endp
end
My cpp file
#include <iostream>
using namespace std;
extern "C" char global_char = 10;
extern "C" short global_short = 100;
extern "C" int global_int = 1000;
extern "C" long long global_ll = 10000;
extern "C" void IntegerAddition(char valueA, short valueB, int valueC, long long valueD);
int main(void)
{
IntegerAddition(3, 5, 10, 20);
cout << "global_char: " << global_char << endl;
cout << "global_short: " << global_short << endl;
cout << "global_int: " << global_int << endl;
cout << "global_ll: " << global_ll << endl;
return 0;
}
My error messages
LNK4042 object specified more than once; extra ignored
LNK2019 unresolved external symbol _IntegerAddition refrenced in function _main
LNK1120 1 unresolved externals
If I comment out the function call, it builds with 0 errors (of course it doesn't run).
I have tried putting an _ in the asm file before the function name, no dice.