大神们来看看:无跳转求字符串长度
要求是内嵌汇编无跳转(即不能用loop,jmp,jne等跳转指令)求字符串长度,函数原型是:
int strlen(char * str)
#include <stdio.h>int strlen(char * string){ int len; _asm { mov edi, string sub ecx, ecx sub al, al not ecx cld repne scasb not ecx dec ecx mov len, ecx } return len;}void main(){ int l = strlen("hello"); printf("l=%d\n", l);}