Tuesday, July 28, 2009

HOW do i add assembley to dev c++?

this is the code i want to add, and as u can see there is assembly i it, so how do i make dev understand that the code contains c++





int GetHp()


{


int hp;


DWORD Char = MyChar( );


//assembly


{


mov ecx,Char


call ZCharacter__GetHPSignatureOffset


mov hp,eax


}


return hp;


}


void SetHp(int Val)


{


DWORD Char = MyChar( );


//assembly


{


(mov ecx,Char


push Val


call ZCharacter__SetHPSignatureOffset)


}


}


int GetAp()


{


int ap;


DWORD Char = MyChar( );


//assemnbly


{


mov ecx,Char


call ZCharacter__GetAPSignatureOffset


mov ap,eax


}


return ap;


}


void SetAp(int Val)


{


DWORD Char = MyChar( );


//assmbly


{


mov ecx,Char


push Val


call ZCharacter__SetAPSignatureOffset


}


}

HOW do i add assembley to dev c++?
Word from word doing a simple Google search....





"The "GNU as" assembler uses AT%26amp;T syntax (not Intel).


Here's an example of such a syntax :





// 2 global variables


int AdrIO;


static char ValIO;





void MyFunction(..........)


{


__asm("mov _AdrIO, %dx") ; // loading 16 bits register


__asm("mov _ValIO, %al") ; // loading 8 bits register


/*


Don't forget the underscore _ before each global variable names !


*/


__asm("mov %ax,%dx") ; // AX --%26gt; DX


} "





So, to answer your question (and unless this FAQ isn't out dated), put your assembly in the __asm() construct.


No comments:

Post a Comment