flat assembler
Message board for the users of flat assembler.

Index > Heap > Best coding practices? (the offspring of XOR vs. MOV debate)

Goto page 1, 2, 3  Next
Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
By the way, what do you think is it a definitely good idea to create a forum called "Best practices" where we all can share information about these kind of code improvements?

Definitely not. It would just result in big flamewar.
Post 06 Mar 2006, 11:15
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
CodeX



Joined: 08 Feb 2006
Posts: 20
Location: Estonia
CodeX
Maybe or maybe not. It's just a question of organizing it.
We have a moderator, we all have some ideas of what is the good way of doing several things, we can have a vote on these ideas if they are "best practices" or aren't.
After voting process completes moderator puts the discussed idea into this forum or rejects it. Nobody else shouldn't post anything there.

This is just one of many scenarios of how to do this.
Anyway I think that we all can benefit from having this kind of knowledge database. At the present moment all these hints are hidden among other messages and it's not always possible to find interesting information within reasonable time period even by using "Search".
Post 07 Mar 2006, 08:42
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
well, there are some nice coding practices, which newbies should learn, but you can never say "this is the good one" i think everyone needs to find his own by practice
Post 07 Mar 2006, 08:57
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Thank you Vid, for expressing your thoughts so succinctly and so clearly. May I offer some alternative notions?
First, the term "newbie", while COMMONLY employed, is not English.
thesaurus.com is FREE. You are not obliged to pay anything to use it. Looking up NOVICE, which IS the correct word, one encounters the following alternatives, if you dislike "novice", because of its connotation with certain religions:
learner, apprentice, beginner, recruit, rookie, and my own favorite, neophyte, are all available. I have OFTEN made the following MISTAKE in my own writing, for this circumstance, incorrectly substituting DEBUTANTE, for the correct synonym of novice: DILETTANTE. So, everyone can err (especially ME.)
This brings us to the second point of your remarkable statement. "I think there are some nice coding practices."
OOPS. Wrong. CODING is not a synonym of PROGRAMMING. One writes a program, one creates a program, but one does not (deliberately) CODE a program. The assembler converts human readable text into "machine code", i.e. binary, which, for most normal humans, is UNREADABLE. Some very skillful folks can both read, and think, in hexadecimal, but I have never heard of anyone reading and thinking in 32 bit binary. So, etymologically, there is no such thing as "coding practice", performed by humans. We type PROGRAMS, not CODE. Unfortunately, most of the garfle produced, especially on FASM forum, represents some kind of CODE, not a program, because it is so typically UNREADABLE, which brings us to the third point of your RICH post this morning:
"...but you can never say..."
Hmm. Vid, dear Vid, computer science is a branch of mathematics. This does not mean, that it is perfect, unchanging, or pure. But, it does imply, that certain rules govern its practice, just as other rules govern the practice of other professions, such as agriculture, medicine, economics, or painting. Let's pick a simple example: cutting trees. I agree with you, that there is a degree of FLEXIBILITY associated with the harvest of a forest for timber. One is NOT OBLIGED to follow the same path, apply the exact same sequence of steps to get the tree down, and trim the branches, and carry the log to the sawmill. However, the absolutist position you have proposed: "one can never say", is incorrect. One can absolutely say, that harvesting the forest requires, BY SOME METHOD, the extinction of life of the tree, its uprooting, its demise. So long as the tree remains alive, it has not been harvested.
In programming, there is ALSO an absolute position: either the task, described at the outset (preferably) as the goal of the program, has been accomplished, according to some measure, else, it has not yet been accomplished--the tree yet lives. One CAN SAY "this is the good one", it is the one that WORKS, according to the specification of the particular task. The "bad one", by juxtapostion, is the program NOT YET HARVESTED, awaiting completion.
The final point to make, regarding your stimulating expression today, is this:
"...i (sic) think everyone needs to find his own by practice"
Hmm.
No, Vid, this is erroneous. http://www.gerenser.com/lotf/
"Lord of the Flies" by W. Golding, 1954
http://en.wikipedia.org/wiki/Lord_of_the_Flies
The whole point of civilization is that society (as opposed to individuals) LEARNS and INSTRUCTS the "novice", or "apprentice", so as TO AVOID making the same mistakes. Your philosophy, "...find his own [way] by practice", is also known as ANARCHY.
There is a CORRECT way to program. All other ways, are INCORRECT.
Correct:
Define ALL data prior to use;
Avoid using punctuation, as a substitute for words;
Employ mathematical commands ONLY for mathematical arguments, rather than for logical arguments.
The typical FASM post, on the other hand, ROUTINELY drops in a little data here, a little data there, oops, forgot about that variable, ok, no problem, here we will stick one in right over here. According to your idea, Vid, this method IS EQUALLY VALID to the rigid notion expressed above. As far as obtaining a workable solution, yes, you are correct--your CODE will function just fine. As far as developing a MAINTAINABLE program, however, it will simply be thrown out, by the next team to encounter this unreadable nonsense. The ABSOLUTE, correct way to program, is to define all data, prior to using it.
Smile
Post 07 Mar 2006, 12:35
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
vid wrote:
well, there are some nice coding practices, which newbies should learn, but you can never say "this is the good one" i think everyone needs to find his own by practice


agreed Razz



edit: im still newbie and i like the way i did learn myself...

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 07 Mar 2006, 12:46
View user's profile Send private message MSN Messenger Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Quote:
the term "newbie", while COMMONLY employed, is not English.
English is not a static language, it is always changing and expanding. No single authority can possibly claim to define all English. New words enter the language through common usage. Quoting an online reference work does not constitute proof of any sort about what can be included, or excluded, within English.
Quote:
There is a CORRECT way to program. All other ways, are INCORRECT.
Just like most of English, there is no fixed definition of a (computer) program. Ask ten people what is a computer program and you will get ten different answers. Consult ten different dictionaries and you will read ten different definitions.
Quote:
Define ALL data prior to use
That is probably good advice in many cases but it is not the only way to do things. Different programs (and different computer languages) require different solutions. It all depends on what you need to achieve.

tom tobias: I am curious what you would consider to the the only correct computer language?

PS: tom tobias this is way off topic, but still quite an interesting read.
Post 07 Mar 2006, 13:24
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
tom tobias wrote:
Hmm. Vid, dear Vid, computer science is a branch of mathematics.

What's this math(ematics) anyway? Is it the rule of nature, or is base10 the true or correct base for numbers? Maybe for you, but not for computers. Binary isn't perfect either, but at least it's perfect for computers, 'cause that's how they were designed (guess, by flawed humans)!!
Like you said, computers are not perfect, because they use human intervention (humans created them anyway), and by the way, humans are VEEEEERY flawed, in case you didn't know.

tom tobias wrote:
The whole point of civilization is that society (as opposed to individuals) LEARNS and INSTRUCTS the "novice", or "apprentice", so as TO AVOID making the same mistakes.

Why aren't we robots then, to follow the GUY IN POWER (president, king, emperor, etc..). Is this GUY IN POWER a god (sorry, you don't believe in god, then just substitute the word "god" with someone that is perfect, flawless, makes no mistake, knows everything, etc..). Does this society chose the best and perfect path? I don't think so.

Learning from mistakes is wise, but attempting to teach someone how to use his life/skills is definetely wrong. Would you be happy if someone BIG IN POWER (let's say the "society") tells you that the correct method of writing programs is in binary (hexadecimal)? Would you switch because most of the society uses that method, just because the leader of the society said that? Is he a perfect guy? Is he making no mistake? Is he flawless? Nope.. We have as much freedom as him, in a civilized world of course, and we are as flawed or "perfect" as him.

What if someone learns by another's mistakes, but he suddenly does the same mistake (intentional), in his own way, figuring that he can do it better? Let him choose his path, not telling him what to "execute". That's what makes us different from machines: we can think freely, we each have our freedom, but all come at a price: we are VERY flawed!!

I totally agree with vid, in that people should choose their own path. You know, tom, you are not flawless, and your path is not perfect either!
Sure, no human is perfect, but at least some of us *try* to do better, and not just say "Who cares", you know.. It's the intention that matters most.

tom tobias wrote:
There is a CORRECT way to program. All other ways, are INCORRECT.

How true, but humans will NEVER program 100% correct, because it's their nature of being free and each having different perspectives. Sadly, these "qualities" also lead to "flaws"...

Don't think machines can do it perfectly, because they are designed by humans, and they have some flaws too, but not as BIG as humans. There is one way to program 100% perfect, but beyond our wisdom. Our mind is simply not SUPER-PERFECT either, so we fail to achieve that CORRECT way you mention. For computers, at least, the 100% perfect way to program is hexadecimal, guess why? because computers use hexadecimal (bytes & bits), go figure

That doesn't mean bytes or bits or anything is perfect.. NOTHING IS PERFECT, and expecting something perfect from a human is way, way, way off!!

tom tobias wrote:
Correct:
Define ALL data prior to use;
Avoid using punctuation, as a substitute for words;
Employ mathematical commands ONLY for mathematical arguments, rather than for logical arguments.

WRONG! That's how you think it's perfect, because of how your mind thinks!! I've got news here: YOU ARE NOT PERFECT, you don't choose the correct path! we are not either, but it's absolutely false what you said that. NO HUMAN is perfect, and you can't expect what someone thinks in his way to be correct, since we have freedom, and we all have our paths, WE ARE NOT ROBOTS, we think freely, and EACH HAS DIFFERENT VIEWS & PERSPECTIVES.

Please think again before enlighting us with more of those "pearls" of wisdom.
Post 07 Mar 2006, 19:12
View user's profile Send private message Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7721
Location: Kraków, Poland
Tomasz Grysztar
The_Grey_Beast wrote:
What's this math(ematics) anyway? Is it the rule of nature, or is base10 the true or correct base for numbers? Maybe for you, but not for computers. Binary isn't perfect either, but at least it's perfect for computers, 'cause that's how they were designed (guess, by flawed humans)!!
Like you said, computers are not perfect, because they use human intervention (humans created them anyway), and by the way, humans are VEEEEERY flawed, in case you didn't know.

What has base 10 or 2 to do with someting being mathematics or not? (well, I didn't really understand what you tried to say in those two first questions, so this is a question out of my ignorance).
Actually I would say that computers are perfect in terms of the mathematical model they implement - they are deterministic and work on base of boolean logic, which is just a mathematical model. If the logical integrity is a measure of perfection, then this model is indeed "perfect", as any other model in mathematics - because this is the very sense of mathematics. If we measure the perfection by how the model applies to our reality, then, well, this is perhaps more philosophical problem - but there are branches of mathematics that are quite far from modelling anything from our reality but are still perfectly logical and coherent. We can also look at the perfection of the implementation of model, like the computer in this example - well, sometimes it may have flaws, some instruction may not execute exactly as stated by model (which in this case is in fact given by the manuals for the processor etc.), but if we get rid of such mistakes, I would call it the perfect implementation as long as each instruction always gives the expected (from the mathematical model) results.

PS. We all get very off-topic here, I have to look for the right point to split this topic.
Post 07 Mar 2006, 20:02
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Tomasz Grysztar wrote:
What has base 10 or 2 to do with someting being mathematics or not?

I'm sorry, I wasn't reffering to math anymore. I just said that base10 is how people think, and base2 how computers think, none of which is truly perfect (sure, computers are closer to perfection in this point). sorry again for such ununderstandable paragraph Embarassed
Post 07 Mar 2006, 20:09
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
Quote:
I just said that base10 is how people think

just because you was learnt to think in base 10. If they would learn you base 11 you 'd think in that one. There is nothing special about base 10, it was just "randomly chosen" and now is widely used.

If you see 5FCh, you don't know how much is it and need to convert it to base10 to know... but do you know how much decimal 1213 is? No, it is just a illusion, you can only compare it to smaller / larger numbers, and that can be easily done in any radix.
Post 08 Mar 2006, 08:41
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
vid wrote:
... There is nothing special about base 10, it was just "randomly chosen" and now is widely used....

http://www.alagan.com/Facts.htm
I concur with these authors: the decimal number system evolved from human observation of mammalian extremity digits (fingers/toes.) There IS something special about base 10. It was certainly NOT randomly selected.
Returning to the topic, whence this extract was properly sliced and repositioned into HEAP, here is an interesting description of Leonardo Pisano's (Fibonacci) manuscript from the 13th century "Liber Abaci" (question: does this translate into the PLURAL of abacus????---hint, this is about the same time as Marco Polo's visit to China???)
http://www.goldenmuseum.com/1104HistoryNS_engl.html
"Fibonacci used the word "zephirum" for designation of the Arabian word "as-sifr" being by the literal translation of the Hindi word "sunya", that means "empty" and serves for designation of 0."
OOPS, did you notice that no less an authority than Fibonacci HIMSELF, considered clearing a register on the Intel CPU, to be synonomous with establishing a state of "EMPTINESS", rather than the consequence of performing an XOR Boolean operation? Oh, you mean, I somehow again drifted OFF, off topic, actually in a circle now, back to where the dog was chasing his tail...
Smile
Post 08 Mar 2006, 11:32
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
Quote:
...a state of "EMPTINESS", rather than the consequence of performing an XOR Boolean operation?
Hey this is fun. You are talking semantics to try to define good programming. That is quite a bold thing to do. And you let some guy from the 13th century decide for you how to program. I wonder what you think when you see RBX or ESP. RBX is 'not English' so perhaps we should all not use it because it is 'hard to understand'. Hehe, ESP[1] is perhaps what we all need to do good programming in the 'correct style', if there is such a thing. RAX is an English word, so I guess it is okay to use that register, but surely the meaning[2] will not properly convey the intended use of said register.

In about 5 minutes I found 20 online English dictionaries that define NEWBIE, with part of speech and etymology and everything. My hardback Collins English Dictionary 1998 also lists NEWBIE as a headword. Sorry, but I could not resist using semantics to counter your statement about NEWBIE not being English.
Quote:
"Liber Abaci" (question: does this translate into the PLURAL of abacus?
Okay, I don't mind playing your game for a little while. ABACUS is from Latin so clearly the Latin plural is ABACI. But as is usual with English, such words are used and eventually get an "English" plural also, so ABACI and ABACUSES are both commonly used. Sorry, I got distracted, what was the question?

Anyhow tom tobias, 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? It is such a small thing. Both Intel and AMD have special hardware to make XOR particularly efficient. Would we not be smart to make use of such circuitry since we all paid for it when we bought the CPU?

As a compromise I will now offer a solution to suit everyone. Here is my code now, it is both efficient for the CPU and readable by the English teacher.
Code:
clear_a_register_using_XOR_for_efficiency                       equ xor
general_purpose_data_and_addresing_register_AMD_called_RBX      equ rbx

;some code
;...
        clear_a_register_using_XOR_for_efficiency   general_purpose_data_and_addresing_register_AMD_called_RBX , general_purpose_data_and_addresing_register_AMD_called_RBX
;...    


[1] ESP: extrasensory perception

[2] RAX: (Scottish and Northern English)
verb transitive: to stretch; to strain; to reach; to reach out, hand.
verb intransitive: to stretch; to reach out.
noun: a stretch; a strain.
Post 08 Mar 2006, 12:57
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
tom tobias wrote:
I concur with these authors: the decimal number system evolved from human observation of mammalian extremity digits (fingers/toes.) There IS something special about base 10. It was certainly NOT randomly selected.


Your fingers can express digits 0 to 10, which would naturally result in radix 11 (you can express one digit at a time, with counting raised fingers). With positional numeric system, base 10 has no objective reason.
Post 08 Mar 2006, 13:37
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17271
Location: In your JS exploiting you and your system
revolution
I can count to 33554432 using all the sticky-out-bits of my body, 10 fingers + 10 toes + 2 arms + 2 legs + 1 other[1], that makes 25 bits, in binary = 2^25. Aside: Can you get 26 bits?[2]

[1] Hey, don't be rude now, I meant my head for the other one, honestly you people have you mind somewhere else!

[2] I already warned you about thoughts like that!! Answer: Yes of course, use your tongue Razz

Were in the HEAP so I think this posts counts as valid, no?
Post 08 Mar 2006, 15:44
View user's profile Send private message Visit poster's website Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 975
Location: Czechoslovakia
MazeGen
revolution: but, in the past, there was some woman protesting: "hey, we, women, have only 25 bits, let's stick only to the fingers. Since then, we use decimal base...

Razz
Post 08 Mar 2006, 17:33
View user's profile Send private message Visit poster's website Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
tom tobias wrote:
OOPS, did you notice that no less an authority than Fibonacci HIMSELF

If I become someone IMPORTANT or IN POWER (or someone with authority) does that mean that I'm PERFECT, and everyone should follow me (oops, we're not slaves anymore, we don't expect the TYRRAN to tell us what to "execute")..

That's a weakness from you -- you consider someone in authority to be more perfect/flawless or CORRECT, RIGHT, whatever.. Isn't he still a human too? Does authority make his words TRUE? Or is he "trusted" by other people who don't know how to make their own path, or to choose freely (i.e not choosing something because another one tells you, or forces you Shocked)?

And those 'guys' were not perfect, as they were all humans, just as we are. And since we're not perfect, what makes you think their 'decisions' were the ABSOLUTE CORRECT ones, and that "there's no other better way"?

tom tobias wrote:
considered clearing a register on the Intel CPU, to be synonomous with establishing a state of "EMPTINESS", rather than the consequence of performing an XOR Boolean operation?

Oh man, let's take an example:

Let's say we all speak the computer language. Now, you won't program something "the english way", but rather "the computer way", since, for example, a boolean XOR (guess, computers don't know what is boolean, they don't even know what MOV is, just circuitry) is smaller.. let's TRY to get into the computer's skin, so we don't know words like "boolean", or "move", or something else.. and we don't think in the "humans" way, either, we are just computers for the moment (it shouldn't be that hard to imagine).

We communicate through circuitry here (sure, it's hard for you to believe, but that's because you are not experienced with it, because you learnt english as a child.. sure, no one is experienced with this, as no one learnt this as his 'language' and no one thinks in computer-logic). Now let's get back to our 'fantasy' example...

Now, if you were to choose between the XOR's circuitry (or bytes & bits in the .exe) and the MOV (which takes up more space), wouldn't you choose XOR? After all, imagine this as "an easier path to think", as if you, for example, had 2 options, one which required more thinking (the MOV way), and another which is smaller (thinks easier, quicklier).. I bet you would choose XOR. Note, you don't even know what boolean is in this example!


Not onto the real world: We are humans. We were instructed to use english between us, to communicate (as well as base10 as the base). BUT, that doesn't make these things PERFECT in any case.

Suppose, for example, that english does not exist (and no one knows it exists), but instead a HARDER, LONGER-to-THINK (each word takes at least 25 characters), and we all spoke it, that would make you think "This is the perfect language".. Guess what?? You were wrong if you said that in the situation, because someone could have showed up, and "invented" english, which you would have found MUCH better, so you WERE wrong in this example! Get the point?

English is not perfect.. No language is perfect, as it was just a "decision" of how humans should think, to actually communicate, but that doesn't make it perfect, neither how humans think (we might have thought from other perspectives if we had chose another path from the beginning)!

What's a language anyway? It's a matter of how people 'organize' their thoughts so they can understand each other, communicate. Each one agreed on it (else it would be chaos). BUT, this could have been different. This is how we (at the moment) THINK, in "human-logic" terms. We think it's something natural, something that is the "only-way", and we can't imagine another method of thinking (we say: computers think wierd, I don't know how they really manage to do those computations so quick).. but remember, they were still designed by humans, so they are neither perfect nor "the only way" to do it. From the point of view of math, they are perfect since they produce the correct results (for integers at least), and indeed they ARE almost perfect for math, but this doesn't make math perfect!

Another example: We see and live in a 3D world. WE can't imagine a 4D world, since we never see it, and we say it's "imaginary", and we cannot imagine it by our 'logic'. Now, if we lived in a 6D world, then we all knew the 2D, 3D, 4D, 5D and 6D planes.. but we still said "7D" is impossible to imagine. In short, this is how WE think, so don't expect it to be "the only way" or "the perfect choice".

Back into programming:
Now, we're creating something for the computer, which doesn't THINK in our ways.. WE built it to think in his own language (0 and 1), and that's all. He doesn't know anything else, it's just awaiting instructions. BUT, we are still making FOR him (applications), and being smart enough, we can realize it IS NOT thinking in our ways.. so, we should not attempt to apply statements which we think are more 'logical' for us, and expect the statement to be true, since the computers use another 'logic' and see it from another perspective.

So what makes you think it's a misuse??? The computer reads it and executes it.. he doesn't know about boolean logic crap or funny (imperfect) stuff we based our thinking on. Note, we COULD have thought differently if we started our path differently right from the beginning!

You say: XOR is a boolean logic operator. It is used logically.... etc..
The computer replies: Uh-huh, but I don't get the point. XOR is kinda of 4 NAND gates circuitry (note, he doesn't even know what NAND gates are, but I'm just jokin'), and 2 bytes.. etc

So you see, it may be a misuse of how you think (or us, humans) for the XOR, but it's certainly not a misuse for the computer, guess.. you are making it for him to execute, so... Rolling Eyes (i'm trying to get into his skin and understand it)
And besides, mov eax, 0 isn't a misuse either.. It's just the "harder" way (for the computer). Imagine you having to think for a particular solution to a problem, but you can choose between 2 different ways (to think), one of which is simpler (faster), and easier.. I would hardly believe you choosing the harder method (you want everything easy anyway), so I think you get my point. (same for computers: harder for MOV (bigger), easier for XOR (smaller))

I think you understand that I'm NOT saying computers are perfect. Oh, they are VEERY far from that impossible-to-reach target, but since we code/program for them to execute, it's logical to assume that 0s and 1s ARE the perfect solution for them, because that's how they were designed (imperfectly). If they were designed (imperfectly) with base10, then the perfect solution for them would be to use base10.. BUT, that DOESN'T make base10 neither base2 perfect!! Hope you get my point



Tomasz: I agree with you that computers are very much perfect for mathematics (just as base2 IS perfect for computers, because that's how they were designed)

But remember that what I tried to say is that doesn't make the initial design perfect (in our case, math). Sure, computers might follow the rules of mathematics perfectly (i.e producing the correct solution), and that makes math perfect for them, because they were designed for mathematics (just as base2 was designed (or chosen) for the computers, which makes it 'perfect' for computers, but that doesn't make the initial design (the computer) perfect).
Note though that what I argued about computers following the rules of (imperfect) math, well.. That's not really true -- especially for real numbers (floats), and infinity, but don't count them in our examples, ok Wink


Suppose, for example, that we chose a different numbering system (i.e without negative/0/positive, and without numbers) and we didn't have add's, we had OTHER operators, because we had a 'strange' numbering system (which wasn't even expecting numbers/symbols, i dunno, just some wierd stuff).. Well, we would then say "this is math" and "it's perfect" or "it's the only 'logical' way". sure, (in our example) we didn't even know what a number is, we chose a different approach for math. And it's the same right now.. We (how we humans think) say math is perfect or the only solution (and we think addition, subtraction, multiplication, matrices, quaternions, ARE the PERFECT operations/elements), but if we were to encounter that other 'race' who used that 'wierd' math, we would say "how illogical" to them, and they would say the same to us. In short, neither is perfect!

Perfection is impossible to reach, in all circumstances. Sure, you might say: oh yeah, why don't you show us another mathematics system? OR how can you code sometimes unoptimized, since you say you get into the computer's skin? Well, I'm still a human (which learnt everything just as you), am I not? And I am still flawed/perfect no more, nor less than any other human. but at least I am wise enough to know that WE ARE NOT PERFECT, and our 'inventions' or 'innovations' or 'ways' or 'thoughts' are not perfect either. It's just in our nature to assume we "hold the only way/solution", like in the 3D example. We never saw a 4D world, we never lived in one, so why shouldn't we say "4D is impossible to imagine"? If we lived in a 2D world, then we would have said "3D is impossible to imagine", but it's quite easily to imagine it in this 3D world, so that suddenly made our previous (the 2D example) statement FALSE.. It's not impossible, it's just our imperfect thinking. It's just our nature.


ps: again, i'm very sorry if i wrote something and "makes no sense", as before (with the base10 thingy), and i really hope you get my point this time.
I dunno what caught me to write such a big post, though. Smile
Post 08 Mar 2006, 22:30
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias
Quote:

hey, we, women, have only 25 bits

I think they have a couple of additional anatomical protuberances you may wish to employ...
Quote:

Your fingers can express digits 0 to 10, which would naturally result in radix 11


I don't agree. I believe, historically, the concept of zero was unknown, in the arithmetic of ancient times. I think zero was given a special name, as discussed in that reference cited above, because of its uniqueness....
Quote:

RAX: (Scottish and Northern English)
verb transitive: to stretch; to strain; to reach; to reach out, hand.
verb intransitive: to stretch; to reach out.
noun: a stretch; a strain.


nonsense. RAX is most certainly NOT a word in the English vocabulary.
ESP is an acronym, not a word.
A certain amount of tomfoolery or tomtobiasy is all for the better, but, still, the thrust should be to improve our knowledge of, or, our understanding of, or our appreciation of assembly language, or, at least, to enjoy some light hearted reading. RAX? Sounds dreadful. Must be some sort of Celtic gibberish.
Hier, wir schreiben nur HOCH Deutsch. None of this Niederlandic stuff.
Quote:

Both Intel and AMD have special hardware to make XOR particularly efficient. Would we not be smart to make use of such circuitry since we all paid for it when we bought the CPU?

Gosh, Intel provides segment registers and real mode too. I don't think it necessarily WISE to employ them, though we paid for them.
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 for Boolean constructs. Yes, clearing a register IS a consequence of employing xor when applied to a single operand offered as both source and destination. The primary purpose of this Boolean operator, xor, however, IS NOT to clear the register. The primary purpose is to enable, EASILY, a single instruction to perform an EXCLUSIVE OR operation ON TWO DIFFERENT operands. So, what is WRONG with using this instruction to clear a register, i.e. to employ but ONE operand, repeated, so as to cause the contents to be cleared?
NOTHING. Nothing is wrong. All of the FASM forum folks agree, it can be done. Not only that, everyone agrees, in general, without any hard data to support the notion, that it may be the FASTEST way to clear a register.... The question is NOT whether one CAN do it. The question is whether one SHOULD do it. As in, OPTIMAL. As in IDEAL. As in maximizing the opportunity to MINIMIZE ERRORS, and IMPROVE READABILITY, and SIMPLIFY the program. I understand, and appreciate, and acknowledge, THAT MOST, maybe ALL of the FASM forumers, UNDERSTAND that XOR eax, eax clears a register. I am NOT WORRIED about them. I am worried about the 10 million people currently NOT USING FASM, in part because of the (mis)perception that Assembly language is difficult to use, difficult to learn, difficult to understand, difficult to read. For you, and the VAST majority of the FASM forumers, this is NOT THE CASE. YOU ALL COMPREHEND the CODE which you produce, and have no need of authoring PROGRAMS instead. Programs, as in READABLE. Maintainable. Easily repaired. As long as the FASM forumers insist on MISUSING the Boolean operator to perform a simple clearing operation, thereby confusing the neophyte, the beginner, the apprentice, the net result will be that those 10 million prospective programmers will look elsewhere for a simpler, easier to comprehend solution to make the computer do what they wish. I understand the mentality of the FASM forumers. They are a proud lot. They are not necessarily BOASTFUL, but they feel a sense of ACCOMPLISHMENT. of MASTERY, not only of the jargon, and the acronyms, and the abbreviations, and the terribly convoluted Intel architecture. They have mastered ASSEMBLY language. Hurrah, and they are NOT ABOUT TO CHANGE their habits, or their customs, to make it easier for learners and neophytes to follow what was so difficult for them to understand. That's their privilege, just as it is my duty, to remind people, including FASM FORUMERS, of the "correct" way to PROGRAM, rather than to create CODE.
Smile
Post 08 Mar 2006, 22:37
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
Seriously, how did you think we learn asm? Without that xor 'nasty' trick? If they will never see it, how will they be supposed to know of such 'tricks', and they are valuable to exceed the "limited-human-mind", which apparentely, from your saying, is that it's limited to XOR being only a boolean operator, and they will probably be much more abstracted than they wanted (that's why they chose asm, to understand internals)

But some of us are passioned or otherwise talented at programming (and asm)! That's why we chose it anyway, why not make it a HLL then? Abstract yourself from the CPU, and soon no one will ever understand how the CPU works (if Intel/AMD/companies fall), and we won't have computers anymore, since no one will ever know how to build one again! (just exaggerating a bit).

That's our skill -- at programming in assembly. Not everyone programs 'correctly' in assembly, as I don't program in other HLLs except C, and I don't build spaceships nor any other thing I'm not skilled at. There is only one Picasso, Einstein, or other of these talented men. But note though, that Einstein had one big talent (for example, he was not talented at painting), neither was Picasso talented at physics. Don't expect Picasso to program in asm, as he had a different passion..


But, of course, this limited-XOR-thinking is how you (human) think, and you don't seem to want to be free of this barrier

tom tobias wrote:
The primary purpose of this Boolean operator, xor, however, IS NOT to clear the register. The primary purpose is to enable, EASILY, a single instruction to perform an EXCLUSIVE OR operation ON TWO DIFFERENT operands.

Why? Who said that? Well, I can say something too:

The_Grey_Beast wrote:
The primary purpose of this Boolean operator, xor, however, IS to use whatever internally it does (in bits or circuitry) because it's the computer's instruction and it doesn't know about that enable, EASILY, a single instruction to perform an EXCLUSIVE OR operation... crap, that's just how humans prefer to think or call xor (some humans, though). Remember, you're not doing it for humans to execute, though

Well, which one of the two statements is true? I will put myself in a neutral position: from your perspective, XOR (exclusive or) seems to be a used to perform that boolean operation on two different operands.
From the computer's perspective (or mine, because I *try* to understand the computer), it's just a piece of circuitry, and bits on memory/disk. The xor eax, eax is simpler for him and it's also smaller. Wouldn't you choose the easiest and fastest method if you were to encounter some type of problem, and you had to find a solution, apparentely, that could have been found with 2 methods: one slower (harder), and one faster (easier).. which one would you choose? (I was referring to a problem that your mind had to resolve, not the computer)

Seriously, if you find xor reg, reg hard to read (or other newbies, who by learning asm, should get a deeper appreciation of computers), it's simply that you are either lazy or you put absolutely no effort in your learning.. and why do you choose asm, being the language with which we break the 'abstraction barrier', and free ourselves from our own 'limited-thinking', like XOR being only a simple boolean operator. You think everything is easy? You don't know what true effort is.

Okay, I went through a bit of philosophy in my previous post, but I think it clearly explains all the human-thinking philosophy, and I'm not going to repeat it again.


But don't say that your methods are correct, because I can say my methods are correct, and where will it go? Nowhere.. and which one is the true statement? sure, you'll keep your point and say your method, of course, but keep in mind that you cannot possibly say something is correct as we have a limited mind, and we have freedom, therefore each has their different perspective.

ps: i truly don't think that xor thing is to encourage newbies, but rather the opposite.. Why? In my opinion, it's a must to know it.. because this is the path of non-abstraction, and hiding some tricks (especially when they are, in fact, TRULY logical, only that our 'limited' minds cannot see reality) will either confuse them or abstract them, and THAT'S NOT THE PURPOSE OF ASM!
i.e it's quite logical xor eax, eax zeroes the register. What's illogical, is your thoughts saying it's a misuse of 'boolean' operators. It logically clears the register, not magically, so your saying of it being a misuse is illogical.

And by the way: we are not proud of our 'illogical' xor to clear a register, we are skilled and talented at asm! Not everyone is an assembly programmer, you know?
Post 08 Mar 2006, 23:30
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2466
Location: Bucharest, Romania
Borsuc
tom tobias wrote:
The question is whether one SHOULD do it. As in, OPTIMAL. As in IDEAL. As in maximizing the opportunity to MINIMIZE ERRORS, and IMPROVE READABILITY, and SIMPLIFY the program.

Why shouldn't we do it? After all, the computer executes everything logically, so it means this is logical too...
You're so proficient with human-thinking in that you CANNOT possibly at least understand another's skin (like the computer), or another race, for example. You are limited to your human-thinking, and you think everything works ONLY and EVERYTHING should be limited for what you think it's natural or logical or your limited thoughts (i.e it's logical for XOR to clear a register, but you claim it shouldn't be used).

READABLE depends on what you call readable.
I find xor as readable as mov, since there is no abstraction I take on the journey. So, as long as you say readable to you, then it's quite ok, but we all have different opinions/perspectives, so this is indeed a VERY false statement.
Post 08 Mar 2006, 23:49
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
tom, GB: get drunk sometimes... i believe you'll find out brand new perspective to fill into your thinking scheme Wink
Post 09 Mar 2006, 00:01
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2, 3  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar.

Powered by rwasa.