64,654
社区成员
发帖
与我相关
我的任务
分享
//……
_asm {
cld // make sure we get the direction right
mov ecx, cnt // num of bytes to scan
mov edi, buf // pointer byte stream
mov eax, chr // byte to scan for
repne scasb // look for the byte in the byte stream
jnz exit_memchr // Z flag set if byte found
dec edi // scasb always increments edi even when it
// finds the required byte
mov pRet, edi
exit_memchr:
}
//……
How to use assembly with Dev-C++ ?
The "GNU as" assembler uses AT&T syntax (not Intel). Check out this page for more information.
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 --> DX
}
I am using Windows