Understanding code



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 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
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
mov eax, dword ptr ss:[ebp+8] ; ebp+8 is the file access specifier,
such as "rw"
test eax, eax
je short LABEL2
LABEL2 :

-----------------------------

TIA

Trev

.



Relevant Pages

  • A faster integer->decimal string conversion routine
    ... xor(edx, edx); ... mov(d, eax); ... edi); // Point EDI at the first char in the buffer ...
    (alt.lang.asm)
  • Re: Hex to ascii
    ... d:dword in eax; ... var buffer:char in edi ... mov(eax, edx); ... shr(posn*4, edx); ...
    (comp.lang.asm.x86)
  • Re: Faster HexToBuffer Routines
    ... d:dword in eax; ... var buffer:char in edi ... mov(eax, edx); ... shr(posn*4, edx); ...
    (alt.lang.asm)
  • Re: Fastcode Int64Div
    ... It receives pointers to X & Y in eax and edx ... push ebx // Save EBX as per calling convention. ... push edi // Save EDI as per calling convention. ...
    (borland.public.delphi.language.basm)
  • New Fastcode IsPrime Function
    ... mov edx, $AAAAAAAB ... sub eax, ecx ... mov edi, offset InversePrimes + TableSize*4 ...
    (borland.public.delphi.language.basm)