flat assembler
Message board for the users of flat assembler.

Index > Main > add trick

Author
Thread Post new topic Reply to topic
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER
Hi everyone!

Code:
add cl, cl    


Will it work???

_________________
_______________________________
NSOS
Post 21 Jul 2011, 13:19
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
What is supposed to be the trick?

Will what work? The add will proceed as expected: cl = cl + cl. But you could've verified that yourself in just a few seconds with a test program.
Post 21 Jul 2011, 13:24
View user's profile Send private message Visit poster's website Reply with quote
BOTOKILLER



Joined: 07 Jan 2011
Posts: 154
Location: Ukraine
BOTOKILLER
then what will be faster
Code:
shl cl, 1    

or
Code:
add cl, cl    

???

_________________
_______________________________
NSOS
Post 21 Jul 2011, 13:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
BOTOKILLER wrote:
then what will be faster
Code:
shl cl, 1    

or
Code:
add cl, cl    

???
Nobody knows. Different CPU's, and different surrounding code, will affect the results.
Post 21 Jul 2011, 14:07
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
Moving to Main.
Post 21 Jul 2011, 14:08
View user's profile Send private message Visit poster's website Reply with quote
typedef



Joined: 25 Jul 2010
Posts: 2913
Location: 0x77760000
typedef
i think
Code:
 shl cl,1    
Post 21 Jul 2011, 14:12
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
The correct answer is: they both take the same time on pretty much any architecture and surrounding code, because they are really simple instructions. Not much to optimize there. 1 uop.

The only difference that you can measure is maybe power Smile because shifting in bit logic is a matter of wiring neighbouring bits, but adding needs some fancy xor tricks and ripple carry and what not.

So get your gear out and start measuring those precious pW (pico-Watts) you're saving Wink
EDIT: Maybe its an order of magnitude bigger (the power saved I mean)
Post 22 Jul 2011, 07:03
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< 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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.