Just because RAX is not in your vocabulary does not mean other English speaking people don't have it in their vocaulary. BTW the meaning I gave comes directly from my hardback Chambers English Dictionary 1993. RAX most defintely is an English word and is used in England and Scotland. You would do well to research your answers before proclaiming knowledge of all English.

Quote:

Quote:

if you don't like to use XOR to make a register 'empty' then that is fine by me. But why are you so worked up about others using it?

Ok, that's fair. I have answered this before, but a little repetition is ...
Boolean operators ...

Actually my question was about you and why you get upset about it, I already read your response about boolean stuff before.

Quote:

Gosh, Intel provides segment registers and real mode too. I don't think it necessarily WISE to employ them, though we paid for them.

Your argument is not consistent. No one is suggesting that every piece of circuitry needs to be used just because it is there. But even so, we ARE already using them in every operating system. Let's take your argument further, it seems to me that the AAD instruction is woefully underused, therefore we all need to deliberately design our algorithms to make use of this instruction even if it means having to make our code/program twice as long and half as fast.

I am getting a little bored with XOR/MOV now so let's shift the debate to IMUL/SHL/ADD. Here's how it works, I want to double the value in the register ECX. Now I have three options available: "imul ecx,2", "shl ecx,1" or "add ecx,ecx". Which option is 'misusing' the circuitry? Which option is preferable for an English teacher? When I said double was I using boolean or arithmetic? Which option is 'correct'? Let's extend the example. Now, instead, I want to triple the value in ECX. Which should I use: "imul ecx,3", "lea ecx,[ecx*2+ecx]"?

09 Mar 2006, 02:03

Madis731

Joined: 25 Sep 2003
Posts: 2141
Location: Estonia

Madis731

1) About underused features of the processors.
The instructions there are made to make your programming easier, that is why C-language was made: abstraction. When you use these confortable instructions, then you are actually wasting precious resources. Actually you can replace all DIVs with MULs, MULs with SHifths/ADDs/SUBs. Furthermore you can replace SHL with ADDs, which is recommended by Intel and Agner Fog in his optimization manual. You can even replace every SUB with ADD. There is no point in arguing about it. IF you want, you CAN use all the fancy instructions to get your CODE to the market, but if you don't want to, there is no-one out there who can make you.
2) About multiplying.
The multiply instruction is rather fast and convenient so with every new CPU you have to worry less about switching to shifts and adds. When you talked about teachers then its a bit funny that you even mentioned about them. I think that computer programming differs from spoken language so much that you can't draw parallels between them. Your English teacher might laugh about it when you show him/her the code you just wrote. On the opposite your MATH teacher might even get excited. Lets talk about multiplying by 4. When you're in a mathclass, you can write N*4 and the teacher grades you "A" or "5" or whatever system you might have. Think about a math exam, where you write: N=(N+N)+(N+N). That is nonsense, you mathteacher fill "F"ail you ("0"). But when I see code where ADD eax,eax | ADD eax,eax is used instead of IMUL eax,eax,4, that guy/girl can get a pat on the sholder from me

Just some reference for you to see why it is still neccessary to optimize constant multiplies:

Let's take your argument further, it seems to me that the AAD instruction is woefully underused, therefore we all need to deliberately design our algorithms to make use of this instruction even if it means having to make our code/program twice as long and half as fast.

My argument has NOTHING to do with frequency of useage. Your rejoinder is non-sequitur.
ONCE again, for the record, maybe for the VERY LAST TIME, one hopes!
My argument AGAINST use of XOR to clear a register, is this:
XOR eax, eax DOES clear EAX, everyone agrees,
however,
MOV eax, zero is preferable for READABILITY.
Illustration of this point:
Suppose we wanted to put the simple integer value ONE, 1, into a register, let's say, EAX.
We want EAX to contain the value of 1.
How shall we accomplish this?
I would propose:
mov EAX, zero
mov EAX, 1
BUT, I acknowledge, that it is possible instead, to use:
xor EAX,EAX
mov EAX,1
(and I suppose it is also possible to simply write: mov eax,1, i.e. without first clearing the register, though I am so oldfashioned, and behind the times, I would include the (probably unnecessary) EXTRA step of clearing the register.)
So, what have we got:
two ways to accomplish the same goal
xor eax, eax
mov eax, 1
versus
mov eax,zero
mov eax,1
Which method is SIMPLER for a neophyte to comprehend?
End of story
oops, no, not quite the end of story.
no, because now, you see, just to be a little fussy,
now, we insert a REAL BOOLEAN operation.
in fact, an exclusive or, operation

mov eax, zero
mov eax, 1
xor EAX, EDX

WHOOA.
now, all of a sudden, we are using the Boolean operator for its INTENDED purpose. Not to clear a register, but to perform an exclusive or operation. Here's how the same sequence appears using the FASM forum method:

xor EAX,EAX
mov EAX, 1
xor EAX, EDX

Yes, for those well trained, EXPERIENCED programmers, no problem to detect the SINGLE ROMAN LETTER difference between the clearing operation, and the exclusive or operation. HOW IS THE NEOPHYTE to distinguish between that situation, and
xor EDX, EDX
?
Only one roman letter, A, instead of D
EAX
versus
EDX
But, if one has been using xor reg, reg, for the past UMPTEEN thousands of instructions, covering hundreds of pages of code, do you think it is easy to pick out that SINGLE letter, which signifies NOT clearing the EDX register, but rather, performing an exclusive or operation involving both edx, and eax?
So, in summary, the ONLY advantage of using MOV to clear a register, rather than XOR, is that MOV is used for assignment of all other integer values, why not use it to assign the value of zero, as well? For a beginner, a neophyte, a novice, a trainee, an apprentice, THERE IS NO NEED to introduce the complexities of XOR, for the simple task of CLEARING a register, i.e. FOR THE TASK OF ASSIGNMENT OF THE INTEGER VALUE ZERO.
Madis, and apparently Agner Fog, are CONCERNED about times, execution times, wait states, and microoperations.
Hmm.

"But when I see code where ADD eax,eax | ADD eax,eax is used instead of IMUL eax,eax,4, that guy/girl can get a pat on the sholder from me."

That's fine Madis. But, NO WAY does your trainee receive a pat on any anatomical part from me, for writing AND twice, instead of mul once. I don't care if it takes 1000 clock cycles MORE time to perform one multiplication, instead of two additions. THIS IS NOT 1960
Hello, anybody home?
This is 2006.
We are no longer working in the 1970's with 8 bit cpu's
Hello, this is no longer 1980, working with an 8086, which had a performance hit for using certain instructions, compared with others.
WE DON'T NEED to worry about SAVING time in our programs.
WE DO NEED to worry about writing programs that
(a) people can understand--> so that they can modify them at a later date, and
(b) fulfil the requirements of the task, WHICH, IN MY 30 years of assembly language programming NEVER, NOT ONCE, have EVER exceeded the ability of the cpu.
In my experience, without exception, EVERY SINGLE PROJECT, whether in aerospace, or manufacturing, or industry, or for the military, or in health care, or education, EVERY project that failed, (and there were MANY in that unhappy circumstance, especially if I played a significant role!!) FAILED NOT because of code which executed too slowly, BUT BECAUSE NO ONE COULD UNDERSTAND what the predecessor team had been trying to accomplish--and as a result, we, those of us who inherited this unreadable code, were often obliged to jetison entire projects, some of them costing MILLIONS of dollars. Inevitably, the few successes resulted from starting over, and rewriting the entire project from scratch. The kind of silliness above, where we see:

Quote:

lea ecx,[ecx*2+ecx]

instead of mul ecx, 3
is not that atypical, in my experience.
I cannot tell you how many times I have seen, even some senior most programmers on this forum, using shift instructions, instead of simple multiplication or division--using those boring instructions would be too obvious, too easy for everyone to understand!!!

http://dictionary.reference.com/search?q=rax
"No entry found for rax.
Did you mean tax?"

Well if you want to take only one reference source as you only source of information then you will be sadly misinformed on most things in this world. Expand your horizons a little, make a wider search with any of the other hundreds of online dictionaries available all for free. I don't think reference.com is so perfect that we need only go there for our information.

fulfil the requirements of the task, WHICH, IN MY 30 years of assembly language programming NEVER, NOT ONCE, have EVER exceeded the ability of the cpu.

Really? Well I wonder what types of prgrograms you do write. I find many times that a run-time of 4 years from a c-prgram is too long for my taste so I optimise with assembly and get it down to a few months. Doing simulations for most areas of research cannot be done without proper optimisation. If you have no need for it then don't use it, no one is forcing you. But try to understand that other people have different goals from you and may need such things to make a program viable.

Perhaps an example where optimisation was critical for my use. A point counting program for ECC. The standard fare available for download all take many hours just to count one curve. Since I was dealing with 1024 bit parameters the expected number of curves needed before finding one with the desired properties is many hunderds of thousands. I had no choice but to fully optimise the code, in assembly, in order to get it to produce results in a reasonable time span. Okay, for sure I could have gone out and bought a thousand computers and upgraded the power supply to my office and start counting on all the machines, but that is such a waste of resources and space (and money).

10 Mar 2006, 00:48

tom tobias

Joined: 09 Sep 2003
Posts: 1320
Location: usa

tom tobias

revolution:

Quote:

Well if you want to take only one reference source as you only source of information then you will be sadly misinformed on most things in this world.

You would do well to research your answers before proclaiming knowledge of all English.

Madis:

Quote:

Just some reference for you to see why it is still neccessary to optimize constant multiplies

For a "typical" program of 100k lines of instructions, with perhaps, 10% associated with clearing a register, how much additional time does the cpu waste, by employing MOV eax,zero, rather than XOR eax,eax? Is that time, compared with the shorter time needed to execute XOR eax, eax, PERCEPTIBLE? Is it measureable? If two OTHERWISE identical programs, one which used only MOV eax, zero, and the other which used only XOR eax, eax, were demonstrated at a public test facility, with you, Madis, as the judge of performance, COULD YOU DISTINGUISH between the two programs, as a user, not as a programmer scrutinizing the source code?

It all depends on how many times the CPU will execute such instructions. In a critical loop where optimisation is vital you might execute it 1 trillion times or more. Web servers routinely do the same instructions again and again, especially bank servers using SSL, then importance of optimisation cannot be understated.

Optimisation is not for everybody and almost certainly really only for experienced programmers that need to get the critical loops running well. With proper commenting and documentation there should be no disadvantage with using assembly optimisation.

tom tobias it seems you have considerably more experience than everyone else on this board since you have been using assembly since 1976. I am curious what machines you were programming in that year? I am finding it difficult to imagine how optimisation was not of high importance with the limited computers of that era.

For trivial programming tasks executed only once, optimisation is a waste of programmer time, but other more frequently executed code will suffer large performance hits. Microsoft experienced this, which is why they introduced Direct-X. They needed to improve the performance of video animation or else risk losing their market share to other competing systems. The users do notice when unoptimised software is running. Top Chess programs, for the most part, now days are reliant on proper optimisation to be competitive.

10 Mar 2006, 05:21

shoorick

Joined: 25 Feb 2005
Posts: 1605
Location: Ukraine

shoorick

i did not read everything here (a lot of english brings me headake ) but it is interesting discussion although i was not ever programming as job and i'm not professional programmer, i also do it a lot of time. so, just some my thoughts.
1.a lot of programmers treat terms of programming language as language of machine, not as english, even hll. not all of them know english at all, so, reading of that terms does not help to undestand them. as example: when i met word "squeeze" it did not told me more then it sounds like "sneeze" also, if english-speeking men were heard how hll keywords pronounced by non-english-speeking - at least they would not understand them but that people still can write good programms and, when they were need meaningful label, they wrote it in russian, just use latin letters (as well as compilers usually restrict alphabet to basic latin only)
2.code have to be not only readable, writeable also: it is hard to type long labels also, personally, i started from assembly language where labels were restricted to 6 symbols - it stay as a stamp in the mind
3.a lot of things are individual, personal: somebody likes deep ladders, but i personally hate to scroll this code left-right. also macros are stick of two ends: they are very handy, and they hide sense of the code to those, who do not know these macros, etc., etc. and this post are extremelly individual and it is impossible to chage my mind with yours. from other side i do not suggest you any style of work: it is your evolution. if you wish to program in good style, you have to do coding, coding, coding, coding, analyse, gather best, watch others code, analyse, gather best, take it on-arm and again coding, coding... that's all (i need aspirin!!!)

_________________UNICODE forever!

10 Mar 2006, 08:13

Madis731

Joined: 25 Sep 2003
Posts: 2141
Location: Estonia

Madis731

Just an example:
when you convert some DWORD value to ASCII-decimal/binary/etc form then you need to repeatedly divide that value (in EAX) with the base and pick out the modulae. While setting up your EDX where you need to collect another modula its neccessary to clear out the previous result. Not only does your code get a branch misprediction hit of 45-100 clocks on modern CPUs, but when you clear a register with moving instead of xoring or subtracting, you can at least put another clock on every time the loop is taken and when the loop exeeds 16 bytes, you can roughly multiply the time it takes by two.

I have NEVER mentioned about GUI programs that NEED to have all registers cleared by XOR. I'm always refering to hi-speed programs like games and statistical programs, math, physics etc. where the same piece of code gets executed hundreds of thousands of times per second and in the end it makes the difference, wether you used longer/slower instructions or shorter/faster instructions.

Yes, you are ABSOLUTELY right that there is no way you can tell the difference between an optimized and an unoptimized program with a user-interface. Responsiveness in these programs can be pumped up by reasonable algoritms and different styles of laying out your layout to the user. Different priorities to tasks etc. and it has little to do with optimizing single instructions for speed.

10 Mar 2006, 08:14

rugxulo

Joined: 09 Aug 2005
Posts: 2341
Location: Usono (aka, USA)

rugxulo

Make everything as simple as possible, but not simpler. -- Albert Einstein

You don't understand a problem until you can simplify it. -- Leo Brodie

Don’t be afraid to restart from scratch. -- Leo Brodie

Every conditional should cause you to ask, 'What am I doing wrong?' -- Charles Moore

I do find that I rewrite stuff a lot, mostly because it displeases me visually (especially when it starts to become less helpful than I'd like). I don't plan everything out ahead of time, so all my programs tend to begin very kludgy.

I of course, DO NOT ACCEPT, as an ATTRIBUTE, in other words, as somthing USEFUL, the fact that any instruction modifies the flags SO THAT the programmer need not explicitly DECLARE, or DEFINE the status of any particular flag, at the outset of a loop, for example, INSTEAD of reliance upon some other, extraneous instruction's actions on a flag. THIS IS THE BEST WAY TO CREATE CODE, not the best way to write a program. Program flow, or control, depends upon an EXPLICIT declaration of the controlling parameters. Their modification MUST BE EXPLICIT, not changed whimsically, as a side effect of some other instruction, else the person READING this program will not understand the logic. The typical FASM forum response is ? what???
We don't care if the person reading our code is so stupid that they don't remember which flags are affected by which instructions, THAT's THEIR problem, not ours. My attitude is quite different, because I have been obliged to read a great deal of FASM forum type of code. I find it unusable, not just unreadable, but incorrect. It is always MORE difficult to convince a programmer that they have erred, if one cannot read and comprehend their ideas.
But, what about "optimization"?

Quote:

I have NEVER mentioned about GUI programs that NEED to have all registers cleared by XOR

Thank you Madis, for bringing up this point.
Hmm.
GUI
Good. Where was GUI invented, Madis? I used the xerox system in the 1970's. Apple stole it, for the first Mac. What was the cpu in that first Mac? Hmm. Wasn't it the 68000? Then, didn't they change to the 68020? But what about the GUI?
68020 of course, modeled on the EXCELLENT instruction set of the DEC VAX architecture, had no such nonsense as XOR as a means to clear a register. So, what then, Madis, did the architects at Apple do, in order to achieve a GUI, WITHOUT using XOR????
This is nonsense.
One absolutely does NOT need to use XOR to clear a register, whether for GUI, or any other application.
This is a fairy tale, evolved over three decades of responding to Intel's horrible 80x86 architecture. In the beginning, YES, probably for the 8086 itself, XOR may well have offered a SIGNIFICANT performance boost, compared with MOV. In those days, most instructions DID NOT EXECUTE in a single clock cycle. There was no cache, no prefetch, no branch prediction. I can understand that in the late 1970's, someone may have discovered a really great performance improvement using XOR, rather than MOV. I don't know if that is true, but I can accept it on faith.
What I do not accept on faith, is that this distorted, stupid idea, REMAINS valid today.
IT IS NONSENSICAL to employ XOR to clear a register.
The King is wearing NO CLOTHES.
Wake UP.
FASM forum members use XOR to clear a register, for the WRONG reason. They do so, BECAUSE THAT'S HOW THEY HAVE ALWAYS done it, not because it is the best way. All of this argument about SPEED ENHANCEMENT as a justification for using XOR to clear a register, is just fluff, absurd, nonsensical fluff.

Quote:

where the same piece of code gets executed hundreds of thousands of times per second and in the end it makes the difference, wether you used longer/slower instructions or shorter/faster instructions.

SHOW ME THE MONEY!!!!!
WHERE is this mythical program THAT WILL NOT WORK, unless XOR is used, instead of MOV?
There is no such creature.
It is the unicorn of assembly language programming.
SHOW ME the algorithm, the specification document, the data structure analysis, the list of variables, the requirement for I/O throughput, and, IF IT TURNS OUT, that INDEED, program xyz WILL ONLY WORK CORRECTLY, within specification, by using XOR to clear registers "trillions of times", INSTEAD OF MOV, then, I will gladly confess to my crimes, and admit the error of my ways: my arrogance, my unjust DEMAND that the senior most FASM programmers, CHANGE their ways, and program CORRECTLY. By the time someone comes along with an algorithm, and a specification document, and an I/O throughput requirement that illustrates the improbability of success WITHOUT USING XOR instead of MOV, Intel, or AMD, will have tacked on another 0.2 GHZ, and the cpu will indeed successfully perform the task, NOTWITHSTANDING the fact that (horrors) MOV was used, instead of XOR.
THIS MYTH, that one must write gobbledygook CODE, instead of authoring a program, IN ORDER TO SAVE PRECIOUS EXECUTION TIME, is utter NONSENSE. BALONEY. RIDICULOUS.
FALSE.
UNTRUE.
Like Revolution proclaimng that RAX is an English word.
ABSURD.

tom tobias: Since you are so concerned with readability why do you bother to use assembly? By it's very nature assembly is going to be much harder to read and understand. Your comments above about using two lines of code ('mov eax,0' then 'mov eax,1') are new to me. I have never before seen this used or even mentioned as a good coding practice by anyone. You mentioned it was old fashioned, when was this in vogue? 1976?

Quote:

Like Revolution proclaimng that RAX is an English word.
ABSURD.

Some people like to bury their head in the sand and say 'I don't want to believe'. I think if you went to northern England or Scotland and start telling everyone there that rax is not a English word you would probably end up with a broken nose. BTW I don't recommend you try it.

[offtopic]I quite enjoy discussing the English language and dictionaries so I would like to give this a little more discussion, we're in the heap right? Okay, good. Totally off topic here but tom tobias likes to use semantics to dictate how he programs so he started it Many years back when I was young and naive I would think that I could buy a dictionary and it would define for me everything that English had to offer. But after some time I realised that in fact dictionary compilers only actually include words that they think are relevant and useful to the reader, mainly because of space and cost considerations. Consider the concise verses a collegiate, you will obviously get many more words presented to you in a collegiate level dictionary. One day while I was at my local library I discovered the Oxford English Dictionary (OED). It is a fabulous tome. 20 volumes of 1000+ A4 size leaves and takes an entire length of shelving to hold it. Defining words from A-Z just like all the other dictionaries. It showed me just how limited the smaller single volume dictionaries really are. The English language is truely enormous, and everyday in my reading I come across words new to me. And also everyday new words are being adopted into the language making it even bigger. At best, a single volume dictionary might hope to capture no more than 5% of the language. Online dictionaries or not much better, the compilers/sites that do the real work of course require people to subscribe to pay for their efforts so sadly most people won't have access to them. Other free dictionaries often just rehash what has already been done on other websites so the coverage is limited. Occasionally there are some great finds, but mostly just the same boring set of core words every dictionary includes. For people interested in languages I recommend the OED (available on CD), you won't be disappointed. However even the OED cannot capture it all, the researchers have only so many hours in the day just like everyone else so it also occasionally falls short of what would be ideal, but by far this is still the most comprehensive available.[/offtopic]

11 Mar 2006, 02:12

tom tobias

Joined: 09 Sep 2003
Posts: 1320
Location: usa

tom tobias

Quote:

I think if you went to northern England or Scotland and start telling everyone there that rax is not a English word you would probably end up with a broken nose.

Since you are so concerned with readability why do you bother to use assembly? By it's very nature assembly is going to be much harder to read and understand.

OOPS
Revolution just hit the nail on the head
THAT'S IT
In these two sentences, he accomplished what I have failed to do, in dozens of posts to this forum over the past two years.
congratulations.
Many of the non-native speakers of English on FASM forum will applaud this succinct summary. Your post offers a terse rejoinder, well formulated, concise, to the point, direct, and BRIEF. Excellent.
This has been precisely MY POINT. I simply lack the skill to properly articulate it. Thank you Revolution, for assisting me.
Assembly language PROGRAMMING, not CODING, is just as readable, just as clear, just as SIMPLE to comprehend, as PROGRAMMING with ANY other language. Assembly language is not "by its nature" more difficult to read. It is the mediocrity of our efforts, using Assembly language, that makes it difficult to read. It is we, not the language per se, that cause our efforts to be ugly, and fundamentally IMPOSSIBLE to comprehend, for the neophyte. It looks so mysterious, so unfathomable, because most of our efforts on this FASM forum result in CODE. In general, including senior most members of this forum, we create NOT programs, but rather, convoluted snippets of CODE.
Have you read Shakespeare's Sonnet 18?
http://absoluteshakespeare.com/sonnets/sonnets_1-25.htm
How about the sweaty brow?
http://www.adoptabeard.com/poemnook/nonsense/andtherewasagreatgnashingofteeth.htm
Hmm. Same language. English.
Different result.
One is meaningful, artistic, creative, inspirational, eminently readable, and poetic.
The second citation contains no obvious spelling mistakes, however, I have no idea what the creator of this second "poem" is trying to convey. FASM contributions appear to me, very similar to "gnashing of teeth", and very different from the panoply of emotions revealed in the Bard's famous sonnet. Dr. Dandamudi's extract, which I posted to the FASM forum a couple of weeks ago, is very clear, and very readable. His textbook refutes, completely, your notion that Assembly Language programming need be obscure, and difficult to comprehend.

Quote:

Your comments above about using two lines of code ('mov eax,0' then 'mov eax,1') are new to me

Yes, I agree with you. My formulation IS WRONG.
question:
What about this:
XOR eax, eax
MOV eax, 1
?
Have you ever seen that code, here on the FASM forum, instead of
MOV eax, 1
i.e. assignment, without FIRST clearing the register?
I have seen this MANY times, i.e. using XOR to clear a register, then using MOV to make the assignment.
IF it is nonsense to write, (and it surely is!)
MOV eax, zero
MOV eax, 1
then, why is it not ALSO nonsensical to write
XOR eax, eax
MOV eax, 1
(p.s. I don't want to read any NONSENSE about flags. If a PROGRAMMER, as opposed to a CODER, seeks to reset flags, then he/she ought to do so, DIRECTLY, (yes, eek, at the cost of another instruction, oh, horrors, a wasted clock cycle, aagh.)
READABILITY has NOTHING to do with some kind of mythical abstract difficulty of the Intel instruction set. It does have something to do with LOGICAL and comprehensive exposition. Vid suggested in an earlier post, that I could profit from inebriation, I recommend, instead, trying one's hand at writing a sonnet.
Here's my favorite:
http://www.poetry-online.org/milton_when_i_consider_how_my_light_is_spent.htm

11 Mar 2006, 11:59

Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania

Borsuc

What's your problem, tom? Are you trying to turn asm in a HLL?

That's why THERE is asm: for people who can understand the computer logic, and not merely using their english skills to program.

ASM is the language between software and hardware!! Don't expect to read assembly as you would read english, because you don't read hardware with english, WAKE UP.

Assembly is not a HLL, so whatever your reasons are to turn asm and make it readable for everyone who doesn't understand the hardware.. By all means, it's a must to know about hardware in order to read assembly. (note: i put readable in italic, because that's what YOU call readable)

Clearing a register and only then moving a value is absolutely NONSENSE to me, so you see, my dear blind friend, it DEPENDS on who's reading.

mov eax, 0? okay, simpler, maybe not faster, but LARGER in size.. oops, are you trying to turn our code in super-bloated-code done by lazy-bones?

Neophytes (i'll stick to newbies).. hmm, why are there SO many High-level languages out there, I wonder? Why not only one? Because one is enough, many languages CONFUSE the newbies...

Well, there ARE more languages, because EVERYONE has DIFFERENT styles.. One might choose Pascal, one might choose C, one might choose Basic (not Visual Basic)... you would say, of course: Why that NONSENSE Basic?

And he would respond: Shut the fuck up, tom.. Why do YOU use that NONSENSE Pascal? I don't care what you think is READABLE, I say Basic is the MOST EVER READABLE language.. why does he reply in such a manner? and why does he negates your arguments? BECAUSE of his own styles.

tom, you CAN'T expect someone else to follow your styles, or to have your styles, so DON'T say something is more READABLE than another, because that depends on the programmer's styles, got it, blind-guy?

Let me ask you something, and see if you can find an answer: What do you understand from COMPUTER programming? Does that mean that a math teacher, or an english teacher can do it? By all means, he may code in a HLL and get some code to work (even if he DOES NOT TRULY understand the internals), but that DOES NOT make him a computer programmer!! You have to be a computer guy to program/code as a computer programmer.

tom, you're so naive.. if you WANT READABILITY, why don't you use HLLs? Sure, revolution said this before, but if you're so concerned about commercial-crap and don't care about the cpu (i.e "who cares about 3 bytes"), then USE HLLs. Why??
They will generate better code than *your* unoptimized crappy asm! They are easier to read (in fact, easier for an english/math teacher.. I, for example, PREFER asm because of it's UNABSTRACTION and because it actually represents how the COMPUTER works)

No matter what you try, tom, you WILL never get asm as readable for Outside computer-world newbies as other HLLs, and, from a commercial-crap (business) point of view, asm is a bad idea, if written by someone such as you.. Here are the drawbacks (for non-optimized asm, like you suggest):

1. Code is poorer than HLL (i.e Hlls have optimizing compilers, at least, better than nothing (unoptimized asm code))
2. Code is harder to read than HLL (at least, from those 'abstracted' newbies, to which you refer)
3. Coding in asm takes more time (again, from 'abstracted' and 'limited' thinking people, who can't extend their thoughts, because they don't want. YOU encourage them to remain newbies, to NEVER understand the hardware/computer's resources, and to code poor and abstracted code eternally)

so, unoptimized asm is really bad for business, even if it's as readable as you can get, HLLs will beat you in all aspects here.

but tom, dear tom, asm was not designed for this purpose. ASM is the 'computer' newbie's language, not a totally outside-newbie's (who doesn't even know what a CPU is). ASM was designed for it's flexibility and getting near-the-hardware, which allows you to optimize better than any HLL compiler (note, unoptimized HLL code is not necessarily using a poor 'compiler', but rather a poor 'design' of code, because you design your code different if you know how a COMPUTER works (i.e hardware stuff)).

Anyway, when you say neophyte, to what type of neophyte are you referring? To someone who doesn't know absolutely nothing about computers?

Let me put it this way: ASM is NOT the language for them. It's the language for computer newbies, who CAN and WANT TO understand the COMPUTER and it's LOGIC (or language, 0s and 1s), not for some brain-damaged english teacher who thinks PROGRAMMING in LOW-LEVEL should be simpler and straightforward for their limited mind. Sure, there are such languages as Pascal, but that's WHAT makes asm different.

Asm is for computer programmers who UNDERSTAND the computer.

Tom, are you saying you are a beginner (neophyte) asm.. maybe it's true, but what kind of neophyte.. Look at you, YOU DON'T EVEN WANT to understand the computer, yet you claim you're helpless in this "asm" world.. It's because of yourself! Quit at asm if you don't want understand the hardware, but don't say "ASM IS SO HARD TO READ", because you WANT IT TO BE HARD TO READ..

Why do you want it to be hard to read? Because you don't train yourself as a COMPUTER-RELATED programmer, rather you learn the abstracted english-things, and think programming in computers is easy and can be done by ANYONE, even if you don't understand how computers work.. WRONG! You have to be talented and skilled, or at least, UNDERSTAND the damn internals.

You're not helpless in this "asm world", tom. You don't want to understand the computer, and you make yourself helpless. So don't start any of these nonsense before you think a bit.

Asm is not for any neophyte. Rather, it's for those who want to appreciate the computer and it's functions, understanding their logic and internal workings, "those who put efforts in their computer-learning", those who understand that asm is a low-level language, those who appreciate the very idea of a computer, NOT english NOR math, because you're programming FOR THE COMPUTER!

tom, what if I say (it's only an example): "I don't WANT to understand and learn how motorcycles work, BUT I WANT TO BUILD ONE!".. does that mean that motorcycles should be easy to build by someone like me, who doesn't WANT to know and understand them, yet it should be understandable by me? It's because of my own decision. I don't understand and DON'T WANT to do so, then I WON'T BE ABLE TO UNDERSTAND how they work, even less of a chance to build one!

another (final example): go in a country where you don't know the language. You want to converse with the people (without a guide or a translator), yet you don't want to understand their language.. Think a bit, tom. Does that mean that those idiots in that country use a UNREADABLE/UNUNDERSTANDABLE language? Or is it you who is the smartshot, and don't want to understand their language, but claim that "That is unreadable/ununderstandable", and think everything should be english related, because that's how you limited-folk were taught. Try to say that to them, and you'll get a kick in your ass!

In short, it's you who has the fault in here, you're absolutely putting no effort and NO APPRECIATION for a computer, yet you PROGRAM for him. That's the problem with you: "You don't want effort (i.e learning the computer's language/logic), but you DO want to program for it (especially, in assembly, which is the most low-level language available), and you don't want to extend your mind/thoughts to a greater area than your english (saying that newbie is NOT an english word, and supporting YOUR decision, suggests that you are CLEARLY blind from other areas except YOUR good'ol'knowledge, and YOU don't want extend that knowledge)"

sorry tom, but don't expect to code well in asm if you DON'T want to extend your knowledge to the computer-world. And don't claim you're a neophyte (and you're helpless in this "hard-to-read asm world, my oh my), as putting no effort in learning and understanding does not make you a neophyte, rather makes you ignorant of your task. Neophyte/newbie is one who WANTS to learn something, and puts efforts in it to learn it properly.

Secondly, newbies should only see 'newbie-related' programs. Don't expect a newbie to read, for example, an operating system.

Last paragraph:

Tom, do you think we WERE born with asm? We were newbies at our time (2 years ago I didn't even know asm), but something MAKES us different than you. WE WANT and PUT EFFORT in our assembly-learning (i.e appreciating the computer internals, and NOT using our other skills at asm-coding, rather understanding the computer-logic).

On the contrary: YOU DON'T WANT to put effort, and YOU WANT to use your non-computer-skills to program (and you have even higher expectations, to code in the lowest-level possible language, wahoo.. you crossed the line a bit). That's not a GOOD path for a neophyte, smartass. Go figure!

Last edited by Borsuc on 11 Mar 2006, 14:24; edited 1 time in total

11 Mar 2006, 13:35

Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania

Borsuc

You know what kind of holiday you need, tom? A holiday in a different world, which has NO SOFTWARE, only HARDWARE (and old-style hardware, remember, WITH NO SOFTWARE). And let's see if you would not appreciate the computer-logic then (and appreciate even 3 bytes), as that will surely drive you nuts, especially for your limited-english-style thinking.

11 Mar 2006, 13:49

Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania

Borsuc

tom tobias wrote:

I don't care if it takes 1000 clock cycles MORE time to perform one multiplication, instead of two additions. THIS IS NOT 1960
Hello, anybody home?
This is 2006.
We are no longer working in the 1970's with 8 bit cpu's
Hello, this is no longer 1980, working with an 8086, which had a performance hit for using certain instructions, compared with others.
WE DON'T NEED to worry about SAVING time in our programs.

Ah, but WE DO NEED to get lazy (and I think that's the main purpose, not readability, but rather: "I don't want to optimize, I'm lazy. And I don't want to say I'm lazy.. At least I can say that I meant it to be readable, so it'll work out with unoptimized-garbage code.." or "Every lazy idiot should be able to read my code (remember, we're in asm, the low-level language), even if he doesn't know anything at all about computers"

What effort did you make to bring these to 2006? That's no excuse for you (lazy-bones perhaps) to say that.

This is the kind of attitude I extremely dislike among assembly language programming (but, who are we kidding, you're not a true low-level, assembly language programmer anyway).

This is exactly the HLL programmer's attitude, tom. Why are you using asm? If you want to make asm 'more readable' (at least, for those like you), then it's probably not a good idea, no matter what you try, you will never beat a HLL's ability to be readable. And, since you code such unoptimized in asm, the generated code will be poorer than that of a HLL compiler (which adds a few optimizations). So, assembly from your perspective is not a good idea. Stick to HLLs.

Assembly language is between hardware and software. tom, you DO NOT appreciate the computer enough. Did you built the 8086? Did you understand it? Can you truly say it's garbage, when in fact, your "simpler" things are trash?

The world I explained in my previous post (with only hardware) is perfect for someone lazy like you, at least a year or so.

Were you to create only hardware, then I don't think you would 'throw' the 8086 to 'trash'.

That doesn't mean you have to use it, but please appreciate it's complexitiy, and what it has done. And newer CPU's MEAN performance. That's NO REASON to get lazy and throw resources to trash.

I think I read somewhere:

JMGK wrote:

With the power of the engines todays, the round wheels are obsolete, and with a squared wheel the cars will go forward anyway

And Agner Fog (or others) are not really concerned so much about speed. It's in their nature to appreciate the computers.

tom, higher-performance does not mean easier, nor wasting resources.. mostly among assembly programmers. It's an enormeous work to optimize the CPUs hardware, yet you say something like it's 'just a piece of garbage' (I meant the 8086), at least that's what I understood from your post. The resources should not be wasted, no matter if you have 4GB or 1MB. What big effort did you do, tom? I'd like to know, and then you can say "I don't care".

For example, having 4GB RAM is no 'excuse' for you to write a super-bloated-notepad which requires 256MB. But the fact is, the appreciation. If there were only people like you in this world, tom, we wouldn't even have computers today, think.

EDIT: Somehow, you claim SPEED is not important. If Microsoft (or anyone) releases a free optimizing compiler, will you use it? If so, why, because SPEED is not important?

So you see, your words are just a diversion. You simply don't want to say "I'm lazy", and let someone else (i.e the compiler or the CPU) do the work for you.. and you have also such an attitude that you then say "who cares about that compiler/cpu", yet you did use it, and never put the effort to do it yourself (i.e build it).

What about this:
XOR eax, eax
MOV eax, 1
?
Have you ever seen that code, here on the FASM forum, instead of
MOV eax, 1
i.e. assignment, without FIRST clearing the register?
I have seen this MANY times, ...

tom tobias I don't recall ever seeing that on this board. Perhaps you can be kind enough to help me find the "MANY" offending code snippets. Some links to the other topics would be good.

FWIW I doubt that assembly can ever be considered as easy to read as something like VB, or even plain BASIC. I have always considered that assembly has a different purpose from HLL's. 1) To make things happen faster, and 2) To do things the HLL's cannot do. Number 1 is a no brainer, if you need it fast then use whatever tools you have available and make it fast. Number 2 is also a no brainer, OS's and other specific hardware related tasks may need special timing or special instructions (like LIDT for example) which make no sense for HLL's. Of course there is probably also number 3) because it is challenging and interesting for many people that like to rax themselves.

[justForFun]Sesame Street was brought to you today by the letters, L, I, D and T and the word RAX. See you all again next time[/justForFun]

12 Mar 2006, 10:37

kake_zinger

Joined: 15 Jul 2004
Posts: 51

kake_zinger

I think we can all concur that the root of the problem is that there is no specialized opcode on x86 architecture to zero all bits of a register. On hardware level this would be a most simple thing to do as opposed to using XOR which actually does an operation; a waste of resources.

Real low level CPU would have all kinds of direct register manipulation operations. What I have missed myself mostly is partitionable registers, for example to be able to use only n bits of a register for buffers, counters etc. Now one needs to zero out the extra bits either after write or before test whichever is more convenient. It would be so much easier to specify EAX being a 7 bit counter register so it would wrap to 0 after 127.

More examples like this can surely be found.

13 Mar 2006, 07:05

Borsuc

Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania

Borsuc

kake_zinger wrote:

Real low level CPU would have all kinds of direct register manipulation operations. What I have missed myself mostly is partitionable registers, for example to be able to use only n bits of a register for buffers, counters etc. Now one needs to zero out the extra bits either after write or before test whichever is more convenient. It would be so much easier to specify EAX being a 7 bit counter register so it would wrap to 0 after 127.

More examples like this can surely be found.

I was thinking of such low-level CPU before, and it might be cool (to control invidual bits, and not only bytes or to have really low-level instructions), but it has a few downfalls (ignoring the circuitry complexity, 'cause I'm not really sure about that). For example, we might need a few more opcodes, but if the opcodes were also at bits, then I guess it wouldn't waste space (i.e mov could take 5 bits, whereas add 8 or 9, something like that). But I think it's a bit complex for the CPU (probably it wastes a bit more power, i dunno ). Nevertheless, interesting idea, though.

14 Mar 2006, 16:49

Madis731

Joined: 25 Sep 2003
Posts: 2141
Location: Estonia

Madis731

Actually the microcode your code gets translated to is in fact in bits in the trace cache. (i)

You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot vote in polls in this forumYou can attach files in this forumYou can download files in this forum