-
ASM and C
I am attempting to mix C++ and Assembly. I have the following code:
MIX.C
Code:
extern void sayhi(void);
extern void quit(void);
int CurrPos = (int)0xb8f9a;
char CurrChar = 'H';
//--------------------------------------------------------------------
int main(void)
{
sayhi();
quit();
}
MIX.ASM
Code:
GLOBAL _sayhi
GLOBAL _quit
extern _CurrPos
extern _CurrChar
SECTION .text
_sayhi: mov byte [_CurrPos],'H'
mov byte [0xb8f9e],_CurrChar
ret
When I try to compile, i get the following error:
Error: COFF format does not support non-32-bit relocations.
This is for the line "mov byte [0xb8f9e],_CurrChar".
Will I have to declare CurrChar as an int so that its 32 Bits?
Paul
-
Maybe...
I'm not sure this will work but you could try:
Code:
asm { //this has to be in the same line
GLOBAL _sayhi
GLOBAL _quit //Your asm code
extern _CurrPos
extern _CurrChar
SECTION .text
_sayhi: mov byte [_CurrPos],'H'
mov byte [0xb8f9e],_CurrChar
ret
}
Note that I've just copy-paste'd your code and don't know any assembly but this is how my book says you write asm in a C++ program.
Hope this helps
-
try adding:
to the top of the asm file. maybe it'll work, maybe not