Question to the experts:
How can I use "ROL" with two variables?
Background: I saw this little piece of code (part) here:
http://www.purebasic.fr/english/viewtopic.php?p=258937
Code: Select all
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : LightWeightEncryptString
; File : LightWeightEncryptString.pb
; File Version : 1.0.0
; Programmation : OK
; Programmed by : Hroudtwolf
; Modified by : Guimauve
; Date : 09-10-2008
; Last Update : 31-03-2009
; Coded for PureBasic V4.30
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Enumeration
#LIGHTWEIGHT_ENCRYPT
#LIGHTWEIGHT_DECRYPT
EndEnumeration
Procedure.c Private_RotateChar(Value.c, Direction.b)
Select Direction
Case #LIGHTWEIGHT_ENCRYPT
CompilerIf #PB_Compiler_Unicode
! rol word [p.v_Value], 2
CompilerElse
! rol byte [p.v_Value], 2
CompilerEndIf
Case #LIGHTWEIGHT_DECRYPT
CompilerIf #PB_Compiler_Unicode
! ror word [p.v_Value], 2
CompilerElse
! ror byte [p.v_Value], 2
CompilerEndIf
EndSelect
ProcedureReturn Value
EndProcedure
;---- snip ----
was answeredis it possible, to change the fixed amount of roled bits (=1) to a dynamic value (e.g. in dependency of the character position)?
But how is this done?2) Yes, of course. Just change the 2nd operand of ROL/ROR to a variable.
I tried
"! rol byte [p.v_Value], byte [p.v_Bits]",
"! rol byte [p.v_Value], [p.v_Bits]" and
"! rol byte [p.v_Value], p.v_Bits"
with "Bits.b" as extra argument for calling the Procedure:
What is the correct way?Procedure.c Private_RotateChar(Value.c, Direction.b, Bits.b)