It is interesting to read these chapters in PDF:

Code Optimization

Unfortunately, don't appears to talk about assembly language optimization.
Posted on 2004-06-15 14:19:45 by Opcode
I had to smile at these paragraphs:

"For brevity, I will provide one example: the result of compiling the bubble-sorting program using Microsoft Visual C++. It is unlikely that you will improve this code significantly without suffering serious brain damage."

"Local variables are addressed directly via ESP. This save one register (EBP) for other purposes. Programmers can't quite do this. Addressing via ESP requires the location of the local variables to be recalculated every time the stack top is moved (i.e., when arguments are passed). This is very tedious and inconvenient for humans."

"mov ebp,
The value of the leftmost argument, the pointer to the sorted array, is loaded into EBP. Only compilers use this method to access arguments; programmers can't use it."

"lea eax,
EBP is added quickly to 4. The result is sent to EAX. Few programmers know this trick; most of them implement this task in two steps:
MOV EAX, EBX\ADD EAX, 4"
In the code, EAX is used later only to access and two times each. He apparently didn't seem to notice what should be obvious to most of you...

I decided to check his claim. So, I set aside a spare minute to rewrite the function:


BubbleSort:
push esi
push ebx
mov ebx,[esp+16] ; length
dec ebx
jz done
mainloop:
mov esi,[esp+12] ; table of signed DWORDs to sort
mov ecx,ebx
xor edx,edx
otherloop:
lodsd
cmp eax,[esi]
jle noexchange
xchg [esi],eax
mov [esi-4],eax
inc edx
noexchange:
loop otherloop
dec edx
jns mainloop
pop ebx
pop esi
ret

This is 36 bytes long, which is a 48% reduction of Mr. Kaspersky's code! (It is also 31% smaller than his figure of an assembly implementation) Therefore you might not want to take this author seriously...
Posted on 2004-06-15 22:04:27 by Sephiroth3
He's right about the manual ESP access, though - as in, "using it everywhere all the time" - that WOULD be tedious to handcode.

A lot of the statements you can't do much but smile about though :)

As for your optimization... is it faster, or just smaller? Size is more or less irrelevant, but speed matters...

Anyway, I didn't bother to read more than a few pages of the stuff, there was too much and I was tired. The things you have quoted seem more or less silly, but what about the rest of it? The antiviral toolkit from Kaspersky labs is pretty neat, so even if these example of asm skills seem ho-humm, they do know how to do highlevel coding...
Posted on 2004-06-15 22:37:09 by f0dder
The only problem that I see for esp, is when you align at runtime the esp :S.
Posted on 2004-06-15 22:58:09 by rea
I have the ebook of <<A-LIST.Code.Optimization.Effective.Memory.Usage>>


Is there someone want me to upload?
It is about 10M(chm)
Posted on 2004-06-15 23:15:51 by qiu
Definitively, I will not buy this book :grin:
Posted on 2004-06-16 11:07:40 by Opcode

I have the ebook of <<A-LIST.Code.Optimization.Effective.Memory.Usage>>


Is there someone want me to upload?
It is about 10M(chm)

I very much doubt that this e-book is legal, so please don't ask if people want you to upload it.

Thomas
Posted on 2004-06-16 16:30:25 by Thomas
ok !
I wouldn't upload it!
Posted on 2004-06-16 17:53:01 by qiu
f0dder,

"...The antiviral toolkit from Kaspersky labs is pretty neat, so even if these example of asm skills seem ho-humm, they do know how to do highlevel coding... "

Software-> Antiviral Toolkit by Eugene Kaspersky (former virusmaker)

A book-> Code Optimization: Effective Memory Usage by Kris Kaspersky
Posted on 2004-06-16 19:24:41 by lingo12
Hmm, what is the intention of OP's post? I'm confused. Was it "let's have a good laugh"? Then, it does not belong to this section of the forum.

Hey, qiu, if you have it, then dump it. Too bad if you paid for it. It will not help improving your assembly programming skill. Not even C programming skill.

For example, if a C programmer (and, I don't mean a beginner) writes switch{} block with unordered case labels, that usually means there will be special cases of fall-through.

This sample chapter shows C beginners how to blame compilers for his incompetence. I don't claim myself as a C expert, but the chapter is simply ridiculous.

Oh, yes, I should mention the bubble sort quote again. It is hilarious.
Posted on 2004-06-16 22:53:47 by Starless
lingo: oops - :stupid:
Posted on 2004-06-17 05:15:18 by f0dder


I very much doubt that this e-book is legal, so please don't ask if people want you to upload it.

Thomas

I know Kris quite well. He submitted some chapters from his book for public usage.
Posted on 2004-07-05 19:20:06 by The Svin

lingo: oops - :stupid:

hey honest mistake lol, same last names
Posted on 2004-07-07 08:42:21 by x86asm
And another thing Thomas.. its perfectly legal to say "share" ebooks as long as you're not making any profit... Now, I may not know the laws there in China, but I know here in North America were allowed to do such things...
Posted on 2004-07-07 12:18:23 by Malice
Therefore you might not want to take this author seriously...


Throughout chapter Four the author uses phrases like "compiler writers use <this term> to describe <this activity>" In fact, most of the terms he uses are not the ones in common use in books on compiler construction.
Cheers,
Randy Hyde
Posted on 2004-07-07 14:25:21 by rhyde
randall, yes you are right,
this fact can be explained that he's Russian, and the translation is not perfect.
Posted on 2004-07-07 15:02:44 by The Svin
I know people can "share" anywhere...in the internet.
bookz, pornz, softz,...
Today many techniques help them do that...

BUT this board is for your idea, for knowledge.
NOT for legal stuff.

Upload any legal stuff into this board will be an illegal activity.
If you do that, this board will be closed by government.
You know?

They look up this board all the time.
I mean, they are somewhere, nearly us.
:wink:

So please don's ask for them.
Ask for them in another place...
:P

Thank you and best regards.
Posted on 2004-10-21 00:48:54 by nhnpresario


Software-> Antiviral Toolkit by Eugene Kaspersky (former virusmaker)



I doubt that Eugene was a virusmaker. And if he was so, he would do everything to protect that information :)
Posted on 2004-10-21 05:00:13 by lifewire
Well, he can do well both things. (E.Kaspersky)
Firstly in his youth his was facinated by the subject itself - everything related to how viruses works, and for educational purposes collected them, analyzed and wrote samples to check some vir-ideas.
To win your enemy you have to learn to think as your enemy.

BTW. They are different those Kaspersky :) The book sample is of Kris,
he has nothing to do with Eugene Kaspersky.
Posted on 2004-10-21 06:39:09 by The Svin