"shl" asm instruction

Just starting out? Need help? Post your questions and find answers here.
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tex.

Hi,

How to use the "shl" ASM instruction.

For the moment, i emulate the SHL like this: (and it's very, very slow

Code: Select all

 
Procedure  shl(value,bit)
 For x = 1 To bit
 value * 2
Next
ProcedureReturn value 
EndProcedure


Repeat ; debug window


 a= shl (Random (10),2)

 b= shl (5,8)
 Delay (100)
ForEver
Thanks for your help, TEX



[url]mailto:texmex@cybercable.fr[/url]
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Pupil.
Hi,

How to use the "shl" ASM instruction.

For the moment, i emulate the SHL like this: (and it's very, very slow

Code: Select all

 
Procedure  shl(value,bit)
 For x = 1 To bit
 value * 2
Next
ProcedureReturn value 
EndProcedure


Repeat ; debug window


 a= shl (Random (10),2)

 b= shl (5,8)
 Delay (100)
ForEver
Thanks for your help, TEX



[url]mailto:texmex@cybercable.fr[/url]

There are easier ways, use the '>' operators.
example:

Code: Select all

a = b>3 ; shift down b 3 steps and store result in 'b'
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tex.

great !!!

too easy

and thanks
Hi,

How to use the "shl" ASM instruction.

For the moment, i emulate the SHL like this: (and it's very, very slow

Code: Select all

 
Procedure  shl(value,bit)
 For x = 1 To bit
 value * 2
Next
ProcedureReturn value 
EndProcedure


Repeat ; debug window


 a= shl (Random (10),2)

 b= shl (5,8)
 Delay (100)
ForEver
Thanks for your help, TEX



[url]mailto:texmex@cybercable.fr[/url]

There are easier ways, use the '>' operators.
example:

Code: Select all

a = b>3 ; shift down b 3 steps and store result in 'b'
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by skypa.

And the easiest way :

Just take 'SAL' with inline Assembler. SAL is equal to SHL, only the NASM Syntax.

--
SAL EAX, 7
--



skypa
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by tex.

perhaps more speed...

thanks


And the easiest way :

Just take 'SAL' with inline Assembler. SAL is equal to SHL, only the NASM Syntax.

--
SAL EAX, 7
--



skypa


BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by fred.

And THE easier way:

a*2 ; this is like a << 1 or SAL a,2 or anything.

PureBasic is an Optimizing compiler, which mean than all operations (for example this multiplication) will be changed with faster command when possible.

Fred - AlphaSND
Post Reply