Re: Understanding code
- From: spamtrap@xxxxxxxxxx
- Date: 26 Oct 2006 12:38:40 -0700
Trev kirjoitti:
Hi all,
Sorry to burden this newsgroup, but I'd like to ask a few more
questions.
Part of what I am doing is learning by example, looking at other
assembly language routines
and trying to figure out what is going on, but the following two
snippets of code have me stumped.
They are connected with fopen() and fprintf() calls.
Can anyone help?
--------------------------------
mov edi, dword ptr ss:[ebp+c] ; [ebp+c] contains a pointer to a string
that gives file format information, such as "%s%s"
xor esi, esi
mov bl, byte ptr ds:[edi]
inc edi
test bl, bl
.
.
.
mov dword ptr ss:[ebp+c], edi
je LABEL
.
.
.
LABEL:
.
.
.
---------------------------------------
The above just gets a pointer to string, looking for terminating NULL,
and when found, saves pointer to string just after that found NULL
byte, and then jumps to LABEL...
The other bit of code is as follows:
mov edx, dword ptr ss:[esp+4] ; esp+4 is a pointer to the filename to
write to
test edx, edx
je short LABEL2
Get pointer to filename, if none provided go to LABEL2...
push edi
mov edi, edx
or ecx, ffffffff ; // ecx is "typically" 7f, and is an input
argument to this function
xor eax, eax
repne scas byte ptr es:[edi]
not ecx
dec ecx
pop edi
je LABEL2
Get length of filename, if length is zero go to LABEL2...
mov eax, dword ptr ss:[ebp+8] ; ebp+8 is the file access specifier,
such as "rw"
test eax, eax
je short LABEL2
Basically check if file access specifier is given, if not then go to
LABEL2...
LABEL2 :
-----------------------------
TIA
Trev
Hope this helps.
.
- Follow-Ups:
- Re: Understanding code
- From: Trev
- Re: Understanding code
- References:
- Understanding code
- From: Trev
- Understanding code
- Prev by Date: Understanding code
- Next by Date: Re: Understanding code
- Previous by thread: Understanding code
- Next by thread: Re: Understanding code
- Index(es):
Relevant Pages
|