flat assembler
Message board for the users of flat assembler.

Index > Main > Anonymous labels not enough, need anonymous OPCODES

Goto page Previous  1, 2, 3, 4  Next
Author
Thread Post new topic Reply to topic
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 05 Jul 2007, 21:45
vid wrote:
Also note that CMOVcc r32, r32 in 64bit mode clears upper 32 bits of destination operand even if condition is false ;)


What?

JJ
Post 05 Jul 2007, 21:45
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 05 Jul 2007, 22:01
Quote:
What?

Code:
  and r64Dest, $ffffffff ; Done internally
  cmovcc r32Dest, {r32Src|m32Src}    
Post 05 Jul 2007, 22:01
View user's profile Send private message Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 05 Jul 2007, 22:05
kohlrak wrote:
Quote:
While the CMOVxx instruction does get rid of branch prediction, it still imposes a dependency, so you should still try to do branchless solutions if you can.
I have a pentium 4, so i'm assuming that i can't use it anyway... Though i think people could benefit from more than just a mov that's like that.
In pentium 4 you can use CMOVxx. However, this won't work if you transfer the program to a computer with a Pentium MMX, for example...

But for those cases, you can define a macro:
Code:
macro cmovne op1, op2 {
je @f
mov op1, op2
@@:
}    
Or, if you want:
Code:
macro cmovne op1, op2 {
local condition_was_not_met
je condition_was_not_met
mov op1, op2
condition_was_not_met:
}    
Quote:
Quote:
The spell checker of firefox2 works pretty well and isn't too bad.
Last time i tried firefox, it didn't work for some unknown reson. Firewall wasn't blocking it, but for some reson it didn't work. Anyone have a stand alone solution?
What didn't work, exactly? Take care that you need to configure it explicitly if you use a proxy or something like that...
Quote:
Quote:
They need to use local labels... local labels are perfectly fine, and you'd be an idiot not to use them.
I personally don't bother with local lables, but then again, i've never had trouble with not having enough names either.
Local labels are an useful feature, but it isn't an absolute solution for every naming problem...

You can avoid your problems for long and long, but it won't necessarily correct them...

JJ
Post 05 Jul 2007, 22:05
View user's profile Send private message MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 06 Jul 2007, 01:44
Quote:
What didn't work, exactly? Take care that you need to configure it explicitly if you use a proxy or something like that...


Didn't work as in the thing didn't even attempt to connect to a website.

Quote:
Local labels are an useful feature, but it isn't an absolute solution for every naming problem...


You still havn't explained why.

Quote:
You can avoid your problems for long and long, but it won't necessarily correct them...


Elaborate.
Post 06 Jul 2007, 01:44
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 06 Jul 2007, 19:33
LocoDelAssembly wrote:
Quote:
What?
Code:
 and r64Dest, $ffffffff ; Done internally
cmovcc r32Dest, {r32Src|m32Src}    
This is stupid!

JJ
Post 06 Jul 2007, 19:33
View user's profile Send private message MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 06 Jul 2007, 19:49
kohlrak wrote:
Quote:
What didn't work, exactly? Take care that you need to configure it explicitly if you use a proxy or something like that...
Didn't work as in the thing didn't even attempt to connect to a website.
What about... error messages...
Quote:
Quote:
Local labels are an useful feature, but it isn't an absolute solution for every naming problem...
You still haven't explained why.
I haven't explained why, because it's obvious!
If you look at the nature of local labels, you will understand the problem.
It's simple. Using local labels, you manage to have your symbols split in namespaces, so that you can have more than one symbol with the same name, as long as they are in different namespaces. But if you want to define more than one symbol with the same name in the same namespace, you'll still have problems.
Quote:
Quote:
You can avoid your problems for long and long, but it won't necessarily correct them...
Elaborate.
I cannot elaborate much more and still avoid to go into examples. That's just that: you can always rearrange the way you do things in order to avoid problematic conditions. But there are still many ways to run into this conditions.

In this case, splitting the labels among namespaces is a way to avoid your problem (because it's much less likely to find two similar names in a single function than in an entire program), but it's still possible that the namespace problems hadn't completely vanished.

JJ
Post 06 Jul 2007, 19:49
View user's profile Send private message MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 07 Jul 2007, 00:10
Quote:
What about... error messages...


I believe it was firefox's equivalent to a default 404 page.

Quote:
I haven't explained why, because it's obvious!
If you look at the nature of local labels, you will understand the problem.
It's simple. Using local labels, you manage to have your symbols split in namespaces, so that you can have more than one symbol with the same name, as long as they are in different namespaces. But if you want to define more than one symbol with the same name in the same namespace, you'll still have problems.


Don't have to write the same name in the same namespace.

Quote:
I cannot elaborate much more and still avoid to go into examples. That's just that: you can always rearrange the way you do things in order to avoid problematic conditions. But there are still many ways to run into this conditions.


Well then, don't avoid going into examples.

Quote:
In this case, splitting the labels among namespaces is a way to avoid your problem (because it's much less likely to find two similar names in a single function than in an entire program), but it's still possible that the namespace problems hadn't completely vanished.


I would love to know what the heck you're doing that would cause you to run out of possible names. For 1 letter lables, you have 26 choices. For 2 character examples, you haver your 26*36 (numbers) choices for names, 3 it goes up even more 26*36^2... 4 = 26*36^3... 5 = 26*36^4... And i think you get the idea. Now of course, you're wanting semi-meaningful names, but with 6656 examples for just 5 letter variable names, i'm sure you can make something creative by the time you got to 20 characters.... which would be 26*36^19 possibilities.
Post 07 Jul 2007, 00:10
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 07 Jul 2007, 23:53
Jeronimus Linuxius wrote:
kohlrak wrote:
Quote:
Sometimes we need to alternately test for a different set of characters, and this can complicate things...
You can always set the base to the base of the string.
Correct if I'm wrong, but I think it was YOU who told that jumps flush the prefetch queue!...
Just a little point: This is the so called "loop unrolling" optimization, which is a basic optimization technique that reliably helps improving performance in practically every chip.

It consists in simulating loops by issuing the instructions that the loop would normally do, but with no loops.
For example:
Code:
   xor eax, eax
   mov ecx, 6
@@:
   add eax, ecx
   dec ecx
   jnz @b    
Unrolled it would become:
Code:
xor eax, eax
add eax, 6
add eax, 5
add eax, 4
add eax, 3
add eax, 2
add eax, 1    
Which avoids the infamous prefetch queue invalidations...
Perhaps, you could optimize it even more if you still had the number to add in a register but without looping...

JJ
Post 07 Jul 2007, 23:53
View user's profile Send private message MSN Messenger Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 08 Jul 2007, 01:44
( (N)*(N+1) )/ 2 = N + N-1 + N-1 ... N-(N-1)
;//static __________//generic
MOV ecx,6 ;______ MOV ecx,[var] ;;=(n)
MOV eax,7 ;______ LEA eax,[ecx+1] ;;=(n+1)
MUL ecx ;______ MUL ecx ;;(n)(n+1)
SHR eax,1 ;______ SHR eax,1 ;;DIVIDE BY 2

BUT this has NOTHING to do with the topic of this thread. Which is (in case you've forgotten Very Happy) anonymous labeling is USELESS except to those who a) write sloppy code b) don't take the time to think about or research the algorithm they are using c) refuse to use the simplest of macros (for say: repeated ELSE IF blocks) because making their code clear and standardized would be a burdon to them.

ALSO
I found it funny that no one even touched my idea about making JavaScript the standard MACRO language for compilers Razz


Last edited by r22 on 08 Jul 2007, 16:48; edited 1 time in total
Post 08 Jul 2007, 01:44
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 08 Jul 2007, 04:45
Code:
( (N)*(N+1) )/ 2 = N + N-1 + N-1 ... N-(N-1) 
;//static __________//generic 
MOV eac,6 ;______ MOV ecx,[var] ;;=(n) 
MOV eax,7 ;______ LEA eax,[eax+1] ;;=(n+1) 
MUL ecx ;______ MUL ecx ;;(n)(n+1) 
SHR eax,1 ;______ SHR eax,1 ;;DIVIDE BY 2 
    

haha, I was going to post the same thing but the first "xor eax, eax" unmotivated me because the source could be simplified into "mov eax, 6*(6+1)/2" which doesn't seems to be an unrolling anymore Razz

About JavaScript (first known as LiveScript), is not standard enough, there are slight variations between browsers. Still, you are always welcomed to write a guide of how to use JavaScript with fasm Wink (to later then talk about standarize it among other assemblers).

PS: Check again your generic algorithm and the typo error at first instruction of the static algorithm.
Post 08 Jul 2007, 04:45
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 08 Jul 2007, 07:54
Quote:
I found it funny that no one even touched my idea about making JavaScript the standard MACRO language for compilers


I'll leave it at this, "Be afraid. Be very afraid."

Quote:
BUT this has NOTHING to do with the topic of this thread.


Exactly, which makes me wonder why he keeps bringing it up. It's not like using annonymous lables unravles loops. But if he really wanted to simplify his algorithem to specifically go from 6 to 1 and add them together (rather than starting from a random number), he can easily do the following.

Code:
mov eax, 6+5+4+3+2+1    


Or he could do the math himself then put it in. The assembler dosn't mind it so much.
Post 08 Jul 2007, 07:54
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Furby



Joined: 01 May 2007
Posts: 74
Location: Kraków, Poland
Furby 08 Jul 2007, 10:15
I don't use any of @ because I don't how to use them Wink is there any tutorial how tu use and undetstand them ?
Post 08 Jul 2007, 10:15
View user's profile Send private message Reply with quote
r22



Joined: 27 Dec 2004
Posts: 805
r22 08 Jul 2007, 17:03
kohlrak, I just assumed he picked something simple just to represent an algorithm, more of an unrealistic example just for the sake of representation.

LocoDelAssembly, the only parts of JavaScript that would really be needed for a macro language are the argument passing, write and writeln, string, integer and float handling etc.. all of which are very standardized. The browser specific portions of javascript like HTTPRequest, some DOM handling, and event handling are totally unneeded for the purpose of creating macros.
I thought of JS because it has an easy to learn, simplistic and standardized syntax.
Post 08 Jul 2007, 17:03
View user's profile Send private message AIM Address Yahoo Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 08 Jul 2007, 22:59
LocoDelAssembly wrote:
haha, I was going to post the same thing but the first "xor eax, eax" unmotivated me because the source could be simplified into "mov eax, 6*(6+1)/2" which doesn't seems to be an unrolling anymore :P
Very well! But I was talking about UNROLLING, and not about other optimization techniques. Of course in real world you would not use unrolling for this kind of stuff (dah!), but to other stuffs (for example, when you're processing only two command line arguments it's completely useless to use a loop, and it is more efficient if you simply unroll it completely).
Quote:
About JavaScript (first known as LiveScript)
And even firstly known as ECMA Script, after the institution that standardized it.
Quote:
, is not standard enough, there are slight variations between browsers.
In the wonderful would of W3C, JavaScript is standardized both in syntax and DOMs...
Quote:
Still, you are always welcomed to write a guide of how to use JavaScript with fasm ;)
First, he would need to implement it!

JJ
Post 08 Jul 2007, 22:59
View user's profile Send private message MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 08 Jul 2007, 23:01
r22 wrote:
kohlrak, I just assumed he picked something simple just to represent an algorithm, more of an unrealistic example just for the sake of representation.
Of course...

JJ
Post 08 Jul 2007, 23:01
View user's profile Send private message MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 08 Jul 2007, 23:03
Furby wrote:
I don't use any of @ because I don't how to use them ;) is there any tutorial how tu use and undetstand them ?
It's on FASM manual, last paragraph of section 1.2.3.

JJ
Post 08 Jul 2007, 23:03
View user's profile Send private message MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 08 Jul 2007, 23:04
kohlrak wrote:
Quote:
BUT this has NOTHING to do with the topic of this thread.
Exactly, which makes me wonder why he keeps bringing it up. It's not like using annonymous lables unravles loops. But if he really wanted to simplify his algorithem to specifically go from 6 to 1 and add them together (rather than starting from a random number), he can easily do the following.
Code:
mov eax, 6+5+4+3+2+1    
Or he could do the math himself then put it in. The assembler dosn't mind it so much.
No comments.....

JJ
Post 08 Jul 2007, 23:04
View user's profile Send private message MSN Messenger Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 08 Jul 2007, 23:24
r22 wrote:
BUT this has NOTHING to do with the topic of this thread. Which is (in case you've forgotten :D) anonymous labeling is USELESS
Wrong! The topic of the thread was that local labels are not enough, but we still need anonymous opcodes (according to the thread title)...
Quote:
except to those who a) write sloppy code
Of course, there are people who don't care about commenting their code......... A line with as many characters as needed is, in my opinion, much better to illustrate some algorithmic notes that you would like to pass to the one who wants to read your code.
Instead of creating a label called, for example, ".we_dont_need_to_swap_registers_cause_they_are_already_in_the_correct_order" (which, let me say, is a very stupid name) to jump over a xchg, it's much better to use an anonymous label and comment what we are doing (for example, with the above sentence).
Quote:
b) don't take the time to think about or research the algorithm they are using
Basically, you are suggesting that I try to implement algorithms that I don't understand. Now, I ask: what has this to to with the topic of anonymous labels? Both good and bad algorithms need lots of labels to be coded in assembly, after all...
Quote:
c) refuse to use the simplest of macros (for say: repeated ELSE IF blocks) because making their code clear and standardized would be a burdon to them.
As far as I have noticed, the people that don't use local nor anonymous labels are the very same who don't use preprocessor features extensively. For example, fasm and MenuetOS developers...

And I don't like to include code in macros, As I've already said. I have my own opinions on this: it obfuscates code because macros containing code often corrupt the CPU context without it being obvious for anyone who doesn't have the time to read all the macros.

JJ
Post 08 Jul 2007, 23:24
View user's profile Send private message MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 09 Jul 2007, 00:05
Quote:

And even firstly known as ECMA Script, after the institution that standardized it.

First or latter? And according to Wikipedia it was first known as Mocha (name that didn't appear in the book I read). The creators of this scripting language was the guys at Netscape (this appeared in the book as well).

And about standarization apparently the browsers are not aware of it because you still need sometimes to use special code to make possible the script to run correctly with all browsers. Anyway, r22 already explained the parts that are really needed and those AFAIK behaves the same on all browsers.

About unrolling, I think you should tell that to r22. The quoting you did from me already says "which doesn't seems to be an unrolling anymore".
Post 09 Jul 2007, 00:05
View user's profile Send private message Reply with quote
Jeronimus Linuxius



Joined: 28 Jun 2007
Posts: 37
Jeronimus Linuxius 10 Jul 2007, 23:29
LocoDelAssembly wrote:
Quote:
And even firstly known as ECMA Script, after the institution that standardized it.
First or latter? And according to Wikipedia it was first known as Mocha (name that didn't appear in the book I read). The creators of this scripting language was the guys at Netscape (this appeared in the book as well).

And about standarization apparently the browsers are not aware of it because you still need sometimes to use special code to make possible the script to run correctly with all browsers. Anyway, r22 already explained the parts that are really needed and those AFAIK behaves the same on all browsers.
I don't know...
Quote:
About unrolling, I think you should tell that to r22. The quoting you did from me already says "which doesn't seems to be an unrolling anymore".
I'm hoping that he reads everything, as I usually do... The sentence was not directed specifically to you, although the quote was yours. Of course, it's applicable to you too!

JJ
Post 10 Jul 2007, 23:29
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page Previous  1, 2, 3, 4  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 cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.