You can export a variable with the public
directive on the FASM side, and import it into your C++ code with extern
.
Here's a short example:
// --- test.asm ---
format MS COFF
public counter as '_counter'
section '.data' data readable writeable
counter dd 0x7DD
// --- example.cpp ---
#include <iostream>
extern "C" long int counter;
int main() {
std::cout << "Hello " << ++counter << "!" << std::endl;
return 0;
}
// --- Compile, Link and Run ---
> fasm test.asm
> cl /EHs example.cpp test.obj
> example.exe
// --- Output: ---
Hello 2014!
The example uses the MSVC cl.exe
compiler directly on the command line for illustrative purposes, however in your case it should be trivial to add the fasm .obj output files to link with your code in the VS link project settings.