strlen() isn't easy to re-write in assembly
... at least not for me. I'm still a beginner at this assembly lark (well, x86 assembly at least).
Basically I'm trying to write my own strlen (for nothing more than educational purposes) but I, well, can't. I'm going over array access here:
http://www.geocities.com/SiliconVall...230/index.html
(Have to put up with his terrible english).
So I want to load the first character of the argument stri into a register, is this the right way to go about it?:
Code:
_declspec(naked) int StringLen(char* stri)
{
int l;
_asm
{
push ebp
mov ebp, esp
mov [l], 0
mov eax, [stri]
mov bl, byte ptr [eax]
mov esp, ebp
pop ebp
lea eax, [l]
ret
}
}
I've stepped through it and bl does indeed get loaded with 'm' (oh, I pass the string "my name is LEEEEEEEEE") but I want to iterate it just to make sure. So I need to inc bl each time to access the next element, right?