flat assembler
Message board for the users of flat assembler.
Index
> Main > XOR EAX,EAX Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8 Next |
Author |
|
kohlrak 17 Dec 2006, 20:05
That is indeed true. that's how i layout my programs.
|
|||
17 Dec 2006, 20:05 |
|
RedGhost 17 Dec 2006, 22:00
tom tobias wrote: As my dad used to ask me, "Is your arm broken"? Dude what the hell are you talking about? Tomasz posted an explanation of the XOR instruction from a different "angle" and I suggested with his in-depth knowledge he should contribute the assembly tutorial beginners so desperately want as he is better suited then most. Why would we use XOR, well as the ten thousand people have said before me, the instruction is smaller, the instruction is faster, and we code in assembly for a reason. I don't know why YOU code in assembly, but most of us code for size/speed/control, so when there is a public and common optimization we generally implement it Reading your posts frustrates me greatly. _________________ redghost.ca |
|||
17 Dec 2006, 22:00 |
|
kohlrak 17 Dec 2006, 22:13
i'd like to see him come up with a few simple games and comment every section of his tricks so we have something to learn off of. I only ever remember one trick from anything i've learned to use in assembly and that is using add if i want to multiply anything by 2 other than the eax register. It'd be interesting to see some more "sneaky tricks" like that.
|
|||
17 Dec 2006, 22:13 |
|
vid 17 Dec 2006, 22:29
kohlrak: look at "aam" instruction
|
|||
17 Dec 2006, 22:29 |
|
kohlrak 17 Dec 2006, 22:36
vid wrote: kohlrak: look at "aam" instruction I'm not talking about packed numbers... I'll show you what i mean below. Code: push eax ;to save the "important stuff" from eax mul ebx, 2 mov ebx, eax pop eax can become the following, but more quickly. Code: add ebx, ebx |
|||
17 Dec 2006, 22:36 |
|
vid 17 Dec 2006, 23:12
neither am i. again, do some research. It is often used as a very cruel trick to multiple numbers
|
|||
17 Dec 2006, 23:12 |
|
RedGhost 17 Dec 2006, 23:47
kohlrak wrote:
Code: shl eax, 1 eax is now multiplied by 2 _________________ redghost.ca |
|||
17 Dec 2006, 23:47 |
|
Tomasz Grysztar 17 Dec 2006, 23:53
vid: AAM does the division, it's AAD that does multiplication.
|
|||
17 Dec 2006, 23:53 |
|
kohlrak 17 Dec 2006, 23:55
RedGhost wrote:
That's probably the fastest one yet. XD I'm experimenting with that one a little more... I still can't figure out how AAD or AAM does either... XD I guess it's my lack of understanding of packed numbers... |
|||
17 Dec 2006, 23:55 |
|
LocoDelAssembly 17 Dec 2006, 23:56
BTW, "mul ebx, 2" doesn't exists, though, exists "imul ebx, 2" which is encoded as "imul ebx, ebx, 2" and leaves EAX untouched.
|
|||
17 Dec 2006, 23:56 |
|
Tomasz Grysztar 17 Dec 2006, 23:59
kohlrak wrote: I still can't figure out how AAD or AAM does either... XD I guess it's my lack of understanding of packed numbers... The Intel manuals describe them quite well. AAD operation description from the "IA-32 Intel® Architecture Software Developer’s Manual", Volume 2A: Quote: tempAL ← AL; AAM operation description from the same source: Quote: tempAL ← AL; (note that imm8 is the parameter to instruction, if you don't specify it, assembler assumes value of 10) |
|||
17 Dec 2006, 23:59 |
|
kohlrak 18 Dec 2006, 00:00
LocoDelAssembly wrote: BTW, "mul ebx, 2" doesn't exists, though, exists "imul ebx, 2" which is encoded as "imul ebx, ebx, 2" and leaves EAX untouched. I know, but i'd sooner use the lsh or add for 2, and lsh for 2, 4, 8, 16, 32, and so on. But we have our styles. lol What's the box...? |
|||
18 Dec 2006, 00:00 |
|
WytRaven 18 Dec 2006, 11:57
Quote: Had to look up a couple of words: You had to look up dictionaries to decipher this sentence? The word was 'Yay' by the way, not 'vay', and dictionary.com would have found the correct definition for you just fine. Quote:
Actually no. It would appear that dictionary.com does not extend its definitions into the realm of modern culture, I would suggest you keep digging until you find the real insult. The sentence in it's entirety was dripping with sarcasm just in case you didn't catch that. Quote:
tom, you are irrelevant. The question posted by the OP was to inquire after the reason for seeing things such as xor eax,eax instead of mov eax,0. In particular the OP was wanting to know what advantage these methods had over using the basic mov eax, 0. The answer was given immediately in simple form and then expanded upon by several others. Note that the OP is now enlightened. Nowhere in the OP's post do I see a request to hear you regurgitate your optimized assembly diatribe. For the final time tom, your CODE vs PROGRAMS spiel is ludicrous in the context of assembly language. Moderator: Can we get this thread closed? It really is going nowhere... _________________ All your opcodes are belong to us |
|||
18 Dec 2006, 11:57 |
|
YONG 18 Dec 2006, 13:16
A fast program is good.
A fast program, which makes use of intuitive instructions, is even better. A fast, well-documented program, which makes use of intuitive instructions, is the best. Having said that, I STILL CHOOSE the XOR approach! YONG |
|||
18 Dec 2006, 13:16 |
|
Borsuc 18 Dec 2006, 16:38
Come on, computers are logical.. There is nothing cryptic in Xor eax, eax, otherwise it wouldn't have been computers, right?
Boolean algebra: what does a number xored by itself yield?? pure logic, man! maybe not logic in english-style, however in 1s and 0s style it's logic.. and computers use 1s and 0s, not english |
|||
18 Dec 2006, 16:38 |
|
kohlrak 18 Dec 2006, 21:47
I have a simple system for writing code.
Level 1 (Sent to programers who don't use the language the source is in): Heavy commenting of everything. Level 2 (Sent to programmers of that language): Commenting anything cryptic (xor eax, eax) that might not be instantainiously obvious. Level 3 (for when i don't release the souce): Only notes for myself, if any. Now, if you use level 2 when redistributing your code, there isn't anything too cryptic or complicated, because anything that is complicated, you have a comment there of what it's a synonym for. Examples of code below.. Well, i won't do one for level 1 programming, you can look at my c func example in the examples post and you'll see, quickly, how detailed i am. Example for level 2 is a real example i did for my programming teacher in C++... Code: bool IsPrime(int num){ for (int check1=1; check1!=(((int)num/2)+1); check1++) //Sneaky speed saving algoritham. for (int check2=2; check2!=(((int)num/2)+1); check2++){ int var=check1*check2; if (var==num) return 0; } return 1; } //------------------------------------------------------------------ void main(){ for (int count=2; count!=100; count++) if (IsPrime(count)) cout << count << " is prime!\n"; return; } and my level 3... Code: void Spaces(int a){ a--; // A smiple fix while(a) { cout << ' '; a--; } // Quicker than a for loop return; } //------------------------------------------------------------------ void ITri(int a){ for(int check1=0; check1!=a; check1++){ Spaces(a-check1); for (int check2=0; check2<(check1+1); check2++) cout << '*'; //proc extraout for (int check3=0; check3<check1; check3++) cout << '*'; cout << '\n'; } return; } //------------------------------------------------------------------ void main(){ ITri(4); return; } Note the level 3 example was edited quickly since i really don't have any decent level 3 examples on hand. |
|||
18 Dec 2006, 21:47 |
|
FrozenKnight 16 Jul 2007, 19:39
i know this topic i quite old but i wa looking through it and felt that a few newbs might be misled by it. I'm not sure how Intells documentation has it but AMD has defined special Optimizations towards using xor to clear a register. and has defined it is the perfered method of zeroing a register.
|
|||
16 Jul 2007, 19:39 |
|
tom tobias 18 Jul 2007, 11:07
FrozenKnight wrote: ....and has defined it is the perfered method of zeroing a register. It is absurd to employ a Boolean operator with ONLY A SINGLE OPERAND. The whole point of George Boole's research, published in the Cambridge and Dublin Mathematical Journal, volume III, (1848), pages 183-198, titled, "The Calculus of Logic", was to show systematically the relationship of different groups of two or more operands: http://www.maths.tcd.ie/pub/HistMath/People/Boole/CalcLogic/CalcLogic.pdf FrozenKnight wrote: ...i [I] know this topic i[s] quite old.... George Boole wrote:
I cannot imagine George Boole being concerned with only one single ship floating about somewhere in the Mediterranean Sea. |
|||
18 Jul 2007, 11:07 |
|
vid 18 Jul 2007, 11:16
tom: as i countless time told you, XOR instruction on x86 is not same as boolean XOR. boolean XOR operates on true / false values, but instruction XOR operates on set of 32 true/false values, and modifies one of it's operands. Do not mistake these two.
Last edited by vid on 18 Jul 2007, 11:45; edited 1 time in total |
|||
18 Jul 2007, 11:16 |
|
Goto page Previous 1, 2, 3, 4, 5, 6, 7, 8 Next < Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.