Why push ecx ?
From: sugaray (ruicui_at_sohu.com)
Date: 01/25/04
- Next message: Phil Carmody: "Re: SSE2"
- Previous message: Nudge: "Re: functional languages with inline Intel ASM?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 19:49:51 +0000 (UTC)
Hi, I have a question here, VC7 generated such assembly code for my
strlen()
_strlen PROC NEAR
push ebp
mov ebp, esp
push ecx
mov eax, DWORD PTR [ebp+8]
mov DWORD PTR [ebp-4], eax
$L1:
mov ecx, DWORD PTR [ebp-4]
movsx edx, BYTE PTR [ecx]
test edx, edx
je SHORT $L2
mov eax, DWORD PTR [ebp-4]
add eax, 1
mov DWORD PTR [ebp-4], eax
jmp SHORT $L1
$L2:
mov eax, DWORD PTR [ebp-4]
sub eax, DWORD PTR [ebp+8]
mov esp, ebp
pop ebp
ret 0
_strlen ENDP
the C code of my strlen() is as below
unsigned int strlen(const char *s) {
const char *t=s;
while(*t!='\0') ++t;
return t-s;
}
i don't know why 'push ecx' after the prologue code, ain't edx and eax
in used later in the assembly code, why not push them ? can somebody
point out why for me ? thanx.
- Next message: Phil Carmody: "Re: SSE2"
- Previous message: Nudge: "Re: functional languages with inline Intel ASM?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]