"So, there's no need for this, either?"
YES, no need for this... :lol
But I wondering why you need to preserve registries esi,edi and ebx
in your main proc... :wink
If you don't care about ExitCode
(you don't plan to use GetExitCodeProcess API)
you can just write:
jmp ExitProcess
rather than
INVOKE ExitProcess, ExitCode
You can see my similar example too:
http://www.masm32.com/board/index.php?topic=6729.0
Regards,
Lingo
Later:
Many years ago in high level languages
we learned how to create "good practice" code
and "good coding habits"
For example: Never use GOTO and blal-bla bla... :lol
Today the times and CPU's are different
We learn how to create good code from the
Intel&AMD Optimization manuals; from the book of the A.Fog too..
There are always people ----- who missed the bus
so, don't allow them to try to manipulate your mind
and always ask them for proofs and their code :lol
:lol
Yes but there has always been people who wrote unreadable unreliable code that was unmaintainable in areas where there was no performance gain by writing it in such an obscure manner and thus you have the "world's fastest MessageBoxA" mentaility complete with all the fanfare of a gnat breaking wind. Code obscurity has its place but only when the target audience is NOT supposed to understand the code being written.
The decisive factor in resurrecting assembler from the dead 10 years ago was to put aside the trivial and put your effort into code that mattered, primarily speed critical algorithm design where you actually get something back for your effort. The alternative so often sprouted back then as the "right way" to write assembler code nearly put assembler programming in its grave.
I had just a little time to waste this afternoon so here is a 1k windows coded the old way, something like the code style of 1990. No equates, mindless label names, no commenting and a particularly irritating technique that you would call stack forwarding where the arguments for procedure calles are nested to get some of the procedure calls sequential.
Contrast this disaster to the masm1k example in the masm32 example code and you will see that its no smaller, no faster and has no additional functionality but its sure badly written, unreadable, unextendable and unmaintainable.
.686p
.model flat, stdcall
option casemap :none
externdef _imp__DispatchMessageA@4:PTR pr1
m2wp equ <_imp__DispatchMessageA@4>
externdef _imp__GetMessageA@16:PTR pr4
gms equ <_imp__GetMessageA@16>
externdef _imp__DefWindowProcA@16:PTR pr4
dpro equ <_imp__DefWindowProcA@16>
externdef _imp__PostQuitMessage@4:PTR pr1
pqm equ <_imp__PostQuitMessage@4>
externdef _imp__RegisterClassExA@4:PTR pr1
scln equ <_imp__RegisterClassExA@4>
externdef _imp__ShowWindow@8:PTR pr2
wshw equ <_imp__ShowWindow@8>
externdef _imp__LoadCursorA@8:PTR pr2
lsc equ <_imp__LoadCursorA@8>
externdef _imp__CreateWindowExA@48:PTR pr12
crwe equ <_imp__CreateWindowExA@48>
includelib \masm32\lib\user32.lib
.code
ims db "Slick Huh ?", 0
pcl dd ims
slick_huh:
push ebp
mov ebp, esp
sub esp, 96
push 32512
xor edi, edi
push edi
mov esi, 4194304
mov ebx, pcl
call lsc
mov DWORD PTR [ebp-96], 48
mov DWORD PTR [ebp-92], 3
mov DWORD PTR [ebp-88], OFFSET wpep
mov DWORD PTR [ebp-84], edi
mov DWORD PTR [ebp-80], edi
mov DWORD PTR [ebp-76], esi
mov DWORD PTR [ebp-72], edi
mov DWORD PTR [ebp-68], eax
mov DWORD PTR [ebp-64], 10h
mov DWORD PTR [ebp-60], edi
mov DWORD PTR [ebp-56], ebx
mov DWORD PTR [ebp-52], edi
lea eax, [ebp-96]
push eax
call scln
mov ecx, -2147483648
push 1
push edi
push esi
push edi
push edi
push edi
push ecx
push edi
push ecx
push 13565952
push ebx
push ebx
push edi
call crwe
push eax
call wshw
lea ebx, [ebp-48]
push edi
push edi
push edi
push ebx
jmp mlep
@@: push edi
push edi
push edi
push ebx
push ebx
call m2wp
mlep: call gms
test al, al
jnz @B
leave
retn
wpep: cmp DWORD PTR [esp+8], 2
jne @F
push 0
call pqm
@@: jmp dpro
end slick_huh
[attachment deleted by admin]
As always, it is very intreresting to read a debate between such experimented coders. I think I can tell that I understand all opionions and there is only one conclusion: "The power is yours", as Capitan Planet was saing in a cartoon from my childhood. :):)
Nick
Hutch,
"...unreadable unreliable code..."
I'm very sorry that my code is
"unreadable" for you but I wondering
how you know that it is "unreliable"
when you are unable to understand it? :lol
I'm not guilty that people who understand
my "unreadable" code as bitRake,
The Svin, Nexo, Mirno,etc don't visit
your site
Nick,
To argue against someone who doesn't
understand my code is "causa perduta"
and I can repeat:
"We learn how to create good code from the
Intel&AMD Optimization manuals; from the book of the A.Fog too.."
rather than from Hutch or from his administrators.. :lol
I appreciate their efforts to help new people to start coding in assembly
but this is C like (easy) assembly code rather than "a good assembly code"
Regards,
Lingo
The problem here of course is that the architecture of Windows
IS C code which is very easy to emulate in assembler. If it was pascal or Fortran or basic, it would be just as easy to emulate if you were familiar with both. Where the difference lies is between hack OS code that has C architecture and algorithm design that has any architecture you wish to use. I would rathere spend the time writing algorithms than the world's fastest MessageBoxA as you get something useful for the effort.
My generation grew up both reading and writing code written like assembler dumps so its not like its a big deal
Quote
"We learn how to create good code from the
Intel&AMD Optimization manuals; from the book of the A.Fog too.."
rather than from Hutch or from his administrators.
This may be useful but nothing improves on the clock, optimisation manuals are a reasonable guideline but no matter how "approved" the technique is, if it does not clock faster than other reference code, its a waste of time.
An optimisation manual will never tell you what is worth the effort and what is not, you can use a profiler if you need it but if you have written code long enough, you don't waste the time on the world's fastest MessageBoxA, you put it into time critical algorithm design.
The problem as I see it with elitist code design is that the people who can read it don't need it and the people who most need it can't read it. Any of the old fellas can write complicated unreadable code, that how it was done 15 years ago but the style of code that brought assembler back from the dead was partially structured and highly readable.
"The problem here of course is that the architecture of Windows IS C code which is very easy to emulate in assembler. If it was pascal or Fortran or basic, it would be just as easy to emulate if you were familiar with both."
This is just bla, bla, blah for my CPU
because it understands just machine (assembly) code. :lol
"..with elitist code design is that the people who can read it don't need it ..."
Absolutely Wrong!
Such kind of code is a pleasure for them and valuable source to "crib" some new idea
and this makes the "art of assembly" rather than R.Hyde HLA... :lol
If you meet somewhere bitRake, The Svin or Nexo ask them about that... :lol
Example:
Everyone starts to play piano or violin with the hope one day to become one of the
world's elite musicians rather than to play in the church just on Sunday
again and again the same music forever...
"...and the people who most need it can't read it.
Hence, they must continue to learn assembly outside of your non "elitist"
site, from other sources (sites), for instance: A.Fog site or INtel@AMD sites
with a lot of "unreadable" assembly code and there is no church musician
to tell them "My music is easy "readable" and "reliable"... :lol
Wow, I had no idea my question was so complicated. :lol
and, I happen to enjoy my blazingly-fast msgbox. Thank you very much. :bg (You gotta start somewhere.)
I think Lingo needs to start his own forum. He IS a good programmer. It is just that this stuff has no business in the Campus (or GeneSys).
Paul
I personally think lingo is one of ,if not the best ASM programmer active on this forum and in public ingeneral. I look forward to reading anything he posts :U
:bg
Quote
This is just bla, bla, blah for my CPU
because it understands just machine (assembly) code
You must have a very unique CPU then, my PIVs just run normal x86 instructions up to SSE3. Now it would be fine if you were writing applications to your own OS but this is not the case, when you write Windows code and need to interact with the OS you either comply with its specifications or your code breaks. Its like your local church playing "Rock of Ages" every morning, you may hate it but thats the way it is.
It would not matter if you preferred Windows to have a Fortran architecture, Cobol, Forth, basic or even the 16 bit DOS assembler architecture in command.com and the DOS and BIOS interrupts, Windows has a C architecture of things like zero terminated strings, pointers, unions, structures and is both designed and specified in C, not anything else.
Where you don't have this limitation is when you write your own code that is not API dependent, with an assembler you have full architecture control and can put anything you like together if you can get it to work so its not as if you have any real limitations on what you write yourself.
Now I will make the point again with interfacing with the OS you place whatever the specified arguments require onto the stack and call an address in a system DLL and from there until the API returns you have NO CONTROL AT ALL at what it does. Apart from old tricks like copying an API into local application memory, there is no such thing as an optimised API call.
Highly optimised code is often hard to read but at least you get something for your effort in time critical operations but writing API code in the same manner gives no performance improvement but highly reduced access due to understandability. It is counter productive to make code so obscure that few can read it let alone understand it and use the ideas.
And just to add my two cents, anyone who codes that way is not a professional and is just playing with assembly as a gimmick so they can say, 'see what I did?' Then they wait greedily for the hero worship. Do that in a Corporation and you will find yourself out of a job very quickly. No one is going to allow someone to write unmaintainable code, what happens if you get sick or die. And if you say, "I have the right way. Everyone needs to learn my way." Take a guess what will happen?
Optimization was extremely necessary in the old days when memory and space was at a premium. Now, it is only used in critical situations or by hobbyists to test their skill and have fun. And I have seen some members, here, who are VERY skilled at optimization and their code IS readable!
Paul
Sorta have to agree with Hutch and PBrennick on this matter - maintainability and readability is everything when
working on larger assembler projects. As for lingo's skill in what I've seen of his code - "well - erm - that's nice "
and that's about it then. Why make your life a living hell just to try and save 5 cycles on an API call !? Use your
FANTASTICAL OPTIMIZATION & OLD SCHOOL CODE skills WHERE THEY MATTER and comment it to DEATH.
That to my mind is the mark of an UBER Assembler coder. The rest sounds like Propeganda and unfit for serious debate.
Thanx
Draakie
[/Edit] UBER = German for GREAT // Oops - I thought every-one knew that // So much for Commenting on Comments [/Edit]
Draakie, you are no better than lingo,
lingo writes unreadable code, and you - unreadable reply :P
Quote from: Draakie on March 15, 2007, 06:27:32 AM
That to my mind is the mark of an UBER Assembler coder.
sorry, almost all asmcode went down in performance 50% on newest multicores, because clock freq went down and everyone still is stuck in old thinking programming singlethreaded
sorry, all your asmcode has no hope to perform 6 times faster because you shave a cycle here and there on scalar code and dont intend to learn this skill because of prejudice its not worth learn SSE/SSE2
sorry, most asmcode is tricks with only use general regs, but not seen much optimization tricks on fpu , when every game does transforms etc on fp's and fpu isnt too slow compared to integer anymore, fpu also can do several things in parallel, if you issue operations to right ports etc
once upon a time, in ancient times, 8087 was the only fpu and few had it equipped and it was dead slow, so we always coded with cpu instead(was it 1980's?)
what are you doing still sticking to general regs year 2007??? :naughty:
:toothy
Magnus,
In a brave new world of 64 bit computing which is still some way off, the bottom line for assembler assumptions will be SSE3 where it is appropriate and multiple thread code but it would be mistaken to think that integer registers in 64 bit are past their use by date. There would be so many if this was the case. Originally MMX and SSE instructions and registers were a fudge to get past the limits of 32 bit along with the capacity of parallel processing to be performed in hardware.
As 32 bit assembler was far different to DOS 16 bit, so will 64 bit be different to 32 bit code. Think into the future of many more processors with better hardware control at synchronising parallel threads and you are part of the way there.
To all my "critics":
My best language is C/C++
hence, I can code in assembly like you
but I'm not sure that you can write in assembly like me... :lol
If you disagree with me please publish your optimized
assembly code or shut up! (if you can control yourself) :lol
Will be beter to spend your time for codig rather than for empty bla-bla-blah...
or Hutch will move the topic again :lol
I want to finish with sentence by my great friend Vortex "Code it... That's all..." :lol
Regards,
Lingo
:bg
Your challenge, my choice.
1024 bytes of sheer blazing maximised high performance API coding in pure assembler. Show me how to make this API call faster or the app smaller at the legal minimum of 1024 bytes.
.486
.model flat, stdcall
option casemap :none
externdef _imp__MessageBoxA@16:PTR pr4
MessageBox equ <_imp__MessageBoxA@16>
includelib \masm32\lib\user32.lib
.code
ttl db "MessageBox",0
txt db "Highly Optimised",0
lets_rock_n_roll:
push 0
push OFFSET ttl
push OFFSET txt
push 0
call MessageBox
retn
end lets_rock_n_roll
; Build it with this batch file
@echo off
if exist "opti.obj" del "opti.obj"
if exist "opti.exe" del "opti.exe"
\masm32\bin\ml /c /coff "opti.asm"
\masm32\bin\PoLink /SUBSYSTEM:WINDOWS /MERGE:.data=.text "opti.obj"
dir "opti.*"
pause
PS : Do note this much, the Campus is subject to a specific set of rules that excludes the style of debate you have chosen to start. While I am more than happy to hear your comments as it is useful to demonstrate to programmers how NOT to write unreadable obscure code, it will not be done in the Campus where the rules prohibit extended discussion of this type.
Now is clear for everyone who has a optimization dream about and a
"world's fastest MessageBoxA" mentality... :lol
I can't help you here but you can ask my great friend Vortex
about some secret key of the Polink to make your exe shorter... :lol
Lingo,
Vortex and I have been a team for a long time and I know exactly how he feels about you. You like to drop names and that is your priveledge, but I will not allow you to give others the impression that he is your friend. He is far from it. When you do it, I will speak up. When I banned you from the GeneSys forum, he was and still is in complete agreement with me.
He is polite so he wont go public about it and if you talk to him he will answer in a polite manner but he will NEVER seek YOU out.
By the way, he can code better than you in both assembly AND C++.
Paul
:bg
> I can't help you here
I imagine this is the case but then I am not the one who argued for faster API calls. I have long made the point that hack OS code is hack OS code and NOTHING makes it faster or smaller. I have no disagreement with you over chasing the fastest algo design possible as that is the place for weird, difficult and obscure code (if it makes it faster).
Where that mentality fails is when its applied to specification OS code which is nothing more than hack interaction with the OS for many functions that cannot be done any other way. You can make it far slower to develop, impossible to modify or maintain and with no hope of anyone else reading it but as Paul well pointed out, code designed like that is amateur hobbyist code, not profesional reusable code.
MASM emulates OS specified C style API very well so it is at no disadvantage in producing this type of code but where it really shines is when you need something that is not pre-canned out of the box and there are NO RULES in how you write custom code as long as you can get it reliable and usable.
lingo,
To make it clear, I am never and I was never one of your friends. Please leave all of us in peace.
Geez, why are some people teaming up and moaning at lingo because of his coding style or his POV of Assembly coding? Maybe his code is unreadable to some, but it does the job and that's the important thing, isn't it. And I don't appreciate Vortex's comment in which he encourages lingo to "leave us all in peace" (basically telling him to leave this forum) - lingo is and has been supplying highly-optimized functions for a long time now, so I doubt I speak for myself when I say I want lingo to stay here and do what he's good at - coding speedy, but oh so unreadable to some, functions. Some people, whom I really thought higher of before, really disappointed me in this thread.
And PBrennick, I disagree, I doubt Vortex "can code better" in Assembly AND C++ than lingo, but oh, who am I to say that, I'll probably get flamed now as well.
Whenever somebody hears something they disagree with, they call it flaming. This is very disappointing behavior. Lingo was banned for reasons he well knows. I have made very positive comments about his coding, also. Read the MessageBox thread or even this one.
However, how on earth can you make a statement as to whether he is better than someone else at coding when he has never written and posted a completely functional, useful program. Vortex has, many, many times so where does this information come from?
Paul
Seb,
To avoid any misunderstandings, I never told him to leave the forum. What I am trying to tell is that one should not start threads like this one becoming a flame war.
I don't mind at all if lingo or any other person is better than me, I would rather mind my own business and I would suggest you to do the same, plus I believe that a member of this forum does not need your advocacy to exhibit or prove his particular coding skills.
PBrennick,
I don't consider differing opinions to equal flaming, I can however see the difference between flaming and when someone's posting constructive criticism or an interesting post. And regarding my comment on "Vortex vs lingo", why shouldn't I be able to make such a comment? I've seen some codes from both of 'em, and as far as I'm concerned, I consider lingo to be a better coder. I'm sure Vortex is a great coder and surely in lingo's class, but that's just my personal opinion. How can you make such a comment then? Have you seen what lingo does personally and never publishes here or perhaps anywhere else? Have you seen what he might be doing professionally? I don't think so. Let's drop this "who's the better coder"-crap now, please. It's not what this thread's about.
Vortex,
thanks for clearing that up, but as far as I know, hutch was the one who created this thread based on some off-topic posts in another thread, or am I wrong? I don't think lingo's intentions were to stirr up a flamewar, but I do recognize his right to share his views on the topic of discussion, and what it basically emerged to was a flamewar because people do pick sides, and some post less constructive posts than other.
Seb,
Let's make it simple. lingo is interested in optimization. All of us, we know his talents in this field. If you tell me that a good assembly coder's work is evaluated on his optimization skills, I will not deny it. I am happy with my general programming practices and I have no any problem if x or y can do better than me using his own optimization knowledge. lingo or any other individual can keep it secret and decide to not to release his chef d'oevres or masterpieces to public. The problem is when one comes to prove himself. In my opinion, a mature member of this forum does not to need to prove himself in this way. I don't need it and I believe lingo or any other member of this member does not need to make such an effort.
Vortex,
I agree with what you say, I also think this whole "who's the better coder"-discussion was actually totally unnecessary and off-topic. I don't know why PBrennick sort of (I also share a piece of the blame for responding to it) brought it up anyway, but let's leave it at that.
The only reason why I did was because he was giving the wrong impression about friendship with Vortex. If I had left it go, a lot of people would have reached the wrong conclusion. I am very defensive about Vortex and will remain so. He likes it that way. I have no ax to grind with Lingo or anyone else here and most certainly not you. I just expect people to be truthful, that is all.
As far as this topic goes, I think it is a waste of bandwidth. If it is a discussion on optimization, I think it is a lost art. I have seen some people do some nice things in small procs but no one has ever optimized a complete app on this forum, like an editor for example. When Lingo wrote that Message Pump, I was hoping that there was more to come. I guess not. :'(
Anyway, for some reason the guys who are VERY good at optimization get real quiet whenever Lingo comes around. Would it not be great if someone wrote an editor that was highly optimized to 'truly' see if there IS any point to it all. It is my personal belief that it would not yield much dividends and the only thing anyone would get out of it would be self-satisfaction.
Paul
Why is everyone attacking Lingo? You should be praising him for his various contributions to the ASM community and for helping it grow to what it's become today. Whether you like his personality or not I don't really see the point of saying negative things about him infront of everyone, that's immature in my opinion and should of been handled via PM or not at all. Lingo is without a doubt a highly skilled and talented programmer and a great benefit to anything hes apart of.
Guys,
I have known Lingo for a long time and he is one of those people who has an acutely good understanding of the inner workings of high speed algorithms but that in itself is not a reason to be the critic of a whole host of other people in terms of their architecture. For anyone who has been around for a long time, architecture that is in any sense useful has a range of attrbutes that are the anti-thesis of obscure unreadable code.
For code to be even vaguely useful it must be very clear, well commented, reusable and flexible in its functionality yet here I am critical of Lingo's approach. For having written some brilliant optimisations in algorithms over a period of years, almost none of it survives as useful reusable code so most of the effort is lost. There are at least hundreds of members in this forum who have been writing assembler code since the bad old days when everything was unreadable, unmaintainable and not even vaguely reusable but the difference that raised assembler from the dead in the middle 90s when assembler programming was the laughing stock of the programming market was the combination of very clear code in reusable format and performance that left most of the rest behind.
Reverting back to the architecture of the past brings with it the effects of the past where assembler programming was ridiculed for being unlearnable, impractical and very slow to develop with but there is another factor that was alive and well back when assembler was the laughing stock of programming, the "gee whiz" approach, "ain't I profound, I can write code so complicated and unreadable that no-one else can understand it." The fruits of this approach were seen with the laughter that used to be associated with the mention of assembler programming.
Hutch,
I'm just coming from work and I was surprised...
a lot of emotions here for nothing...
As a owner of this site and if you hate my code
so much just tell my great non-friend Vortex to delete it
and he will do that professionally with big pleasure :lol
If I have more time I will continue our dispute
when I will be finished with my red black trees top-down
insert algo in assembly
The world still use similar algo in "perfect" C/C++ and it is
"very clear, well commented, reusable and flexible in its functionality"
but more details soon... :lol
Seb and E^cube,
I'm happy to see brave and honest people amongst you :cheekygreen:
but please, don't worry so much because we were warned by Hutch
with:
"The Laboratory"
"Post code here to be beaten to death to make it better,
smaller, faster or more powerful." :lol
Regards,
Lingo
Lingo,
> a lot of emotions here for nothing...
Not exactly, when you make criticism you tend to get it in reply. If something is unacceptable, trust me in this much, I don't need to delegate its removal, I have been doing it for years but it tends to be stuff like porn sites, abuse and similar.
You are correct in reference to the Laboratory, the IS the place for advanced, difficult and obscure code but the Campus is NOT. You are neither the first and you will not be the last to have postings moved out of the Campus so you have not been discriminated against. Thats why the moved posting is here where it does not interfere with people who are learning the basics of assembler programming.
The idea of a red/black tree sounds interesting enough, I have occasionally played with tree design but not for a while as I find hash tables are generally faster. It will be interesting to see if your design is sensitive to insertion order in terms of how randomly the tree is constructed. I did play with a design that preferred a reverse sorted input but general balanced tree design seems to prefer highly random data in its input oder to produce maximum speed.
"Not exactly, when you make criticism you tend to get it in reply."
The answer of the topic was:
"Should the pops occur before or after invoking ExitProcess?"
You and some people said "Before" without any proofs
Lingo said "No pops" and tried to prove his opinion
and I can't see criticism from Lingo to others here...
I saw the criticism and bad controlled emotions against Lingo about his opinion
As a free Canadian It was surprise for me and I can't let anyone to make me
feel guilty for nothing ...
Quote from: hutch-- on March 16, 2007, 03:51:22 AM
when you make criticism you tend to get it in reply.
Yes, and that's why Lingo replied to PBrennick's "When we are trying to teach good coding habits there is always some ----- who comes along and, well you know."
He also provided the info [that really
must be made one of the first things to teach in asm tutorials, but it isn't ] about
why and
where ebx/esi/edi should be preserved: in callbacks (because WinAPI uses them for
enumeration). There's no environment-info stored in those regs, it's just that the C compiler Microsoft uses has been implemented with that in mind.
Even a C compiler won't have the stack balanced and ebx/esi/edi popped before ExitProcess() - the compiler pops them after the call, before the current proc's return - which is something never to be executed.
So actually why ebx/esi/edi rules came from win2k/2k3s/xp/vista, but weren't present in win98 and before? Because Microsoft's C compiler's optimization was bad - storing and restoring registers to/from the stack almost always. So, enumeration didn't use those 3 registers accross calls.
Draakie pointed-out what good coding habits basically are, and that should have been the last post in this thread.
Yet, to add: you need knowledge and experience to know why and where these habits have to be applied. And making these habits more strict is up to the coder's judgement in the project environment. Since Lingo has knowledge and experience, he directly pointed to the answer. Sure, in the code he posts here he doesn't put comments - but mind you that it's probably (I'd say "definitely") something he composed in a few minutes after seeing a request on this board - and since the code isn't 5000 lines, commenting isn't necessary. Why not necessary? Someone who isn't good at asm, and doesn't care, won't read comments anyway. Someone who isn't good at asm yet, but wants to learn, will try hard to
think and understand - eventually reading a few references and articles in parallel to studying the code - isn't this a good for one's brain? One who is good at asm and wants to understand how the code works - will simply trace it in one's mind, see if all possible cases are covered via the code, convert the code to his style, and possibly write comments in his own style.
Again, Lingo doesn't post 5000 lines at once - so you really can't judge what his coding habits actually are. And blaming him for indirectly making nuggets/us try to think hard, isn't very valid imho.
My 2 cents.
Let me clear up a number of misconceptions, the OS register preservation rules for 32 bit PE version of Windows was in place in Windows NT 3.5, the specification is even earlier and originates from Intel. In EVERY 32 bit version of Windows the same rules apply. It just happened to be that some win9x versions did a bit of additional hand holding to prevent incorrectly written code from crashing.
I have had people stand up and argue about this set of specifications for many years but the same set of people do not help out when a person learning assembler writes an app that breaks the register preservation rules and crashes for reasons that they don't understand. While it is simple for experienced programmers to see an unprotected use of any of the 5 registers that must be returned with the same value to the OS, it is no joy for a person learning assembler to try and find it if they have been fed bullsh*t about register preservation rules.
Teaching good habits is critical to people learning a complex area of programming like assembler as there is a high failure rate when people attempting to learn this area keep getting code that crashes and they don't know how to fix it. This does not matter to people who are more interested in flaunting how complicated their own code is than actually getting more people to succeed in writing code that works.
Now anyone who has been around for a while already knows that the ExitProcess() API call does not return so it simply does not matter what state you leave the stack or what value you place in system specified registers.
invoke ExitProcess, arg etc ...
ret
Whatever_proc endp
In MASM this translates to something like,
push 0
call ExitProcess
leave
retn [bytecount]
The LEAVE and RETN instructions are never executed because the OS terminates the thread when the ExitProcess() API function is called.
Does this mean you set a general rule to mislead learner programmers so that their code crashes and the don't know why ? I suggest not, if people learn good habits that produce reliable code, they can then lean all of their own bad habits later on the basis of knowledge of exceptions.
Now this translates to the Campus
NOT being the place for debate on these issues, freestyle architecture, deviant techniques and the like all have their place but its not in the Campus. The rule was put in place when the forum was started to exactly address this problem of confusing learners with arguments.
Now in particular to some of Lingo's comments,
Quote
There are always people ----- who missed the bus
so, don't allow them to try to manipulate your mind
and always ask them for proofs and their code lol
Strangely enough those of us who owned MMX boxes in 1996, SSE boxes before 2000, SSE2 boxes shortly after and SSE3 boxes when they became available didn't miss the bus. Boasting wih elitist assumptions does not wash with people who have been writing code since before 1990.
Quote
"We learn how to create good code from the
Intel&AMD Optimization manuals; from the book of the A.Fog too.."
rather than from Hutch or from his administrators.. lol
Having had Intel PDF manuals since they started producing them as technical reference for x86 hardware and having produced the Winhelp version of Agner Fogs earlier optimisation manual, its not as if name dropping on reference material proves any point here, we have all had this stuff for years. Anyone claiming to be te "correct interpreter" of the reference material is patting their own back and making elitist assumptions.
None of these things worry me as I have been the target of criticism for years but I am equally capable of making it in return and in this case I have been willing to do so at the level of producing unreadable obscure code that is rarely ever re-usable. I have made the point before that people who can read it don't need it and those who most need it cannot read it. Any notion that code this bad is delivered as some form of teaching aid to people who have been writing fast reliable code for years is simply more ego massaging with elitist assumptions.