Mihai RUSU wrote:
> Uite ce teste am facut eu.
> [...]

Da, interesant. Am trimis problema in forma originala si pe o alta 
lista. Uitati ce raspuns am primit, poate intereseaza pe cineva:

-------- Original Message --------
Subject: Re: Value to subtract from ESP register?
Date: Wed, 24 Mar 2004 21:37:49 +0000
From: Glynn Clements
To: [EMAIL PROTECTED]

In most cases, gcc rounds the size up to keep the stack pointer
aligned to a 16-byte boundary. If you were to generate functions for
1-byte, 2-byte, 3-byte etc arrays you would note that for arrays of
1-16 bytes (with certain exceptions; see below), it subtracts 24; for
17-32 bytes, it subtracts 40; for 33-48 bytes, it subtracts 56, etc
(the pushed EIP and EBP account for the other 8 bytes). This is
consistent with the fact that the i386 architecture caches data in
aligned 16-byte blocks (sometimes referred to as "paragraphs").

However, it treats sizes of 1, 2, 4 and 8 bytes as special cases,
allocating 4 bytes for the first three cases and 8 bytes for the last.
Again, this very much looks like something which would be done for
optimisation reasons.

If you need to know the specific reasons, you would probably have to
ask the people who actually wrote the code. And even they might not
actually know why. Optimisation tends to involve dealing with opposing
pressures. Any particular technique will speed up some programs but
slow down others; the optimal approach can often only be determined by
trial and error. If a certain combination tends to make code run
slightly faster, it may be adopted without anyone actually analysing
it in detail.


--- 
Detalii despre listele noastre de mail: http://www.lug.ro/


Raspunde prin e-mail lui