Jump to content
Tuts 4 You

Asm Opcode Rol?


ChupaChu

Recommended Posts

I am coding a keygen, and im stuck. I'm writing it in Borlad Delphi 10.

In target AL value is ROL-ed with CL value.

e.g.

ROL 16,32 would give 58 as result! (if using EAX and ECX one would get 580000 all in hex!)

ROL 69,48 would give 69 as result! (if using EAX and ECX one would get 6900 all in hex!)

Now this i canot do in delphi:

1. ROL as such does not exist in delphi (so i cant implement asm code part (c/p) from source target).

2. i tried using SHL - what gives correct/SAME values as ROL if calculating with dword values, but as i must calculate byte values (AL,CL) i get wrong result.

3. implementing asm part in delphi with SHL al,cl gives me a [Pascal Error] : E2107 Operand size mismatch..

Please recomend wht to do?

Thank You!

Link to comment

Sry, I dunno the delphi syntax, but couldn't a byte roling

simply being simulated like this ?

	int AL = 69			// or 16... take AL register
int CL = 48 // or 32... take CL register while (CL > 0)
{
AL ^= 1; // means SHL AL,1
if (AL > 255) // is the 9th bit set ? ...
AL -= 255; // .. then place it into the 1st one !
// Removing the 9th bit -> -256
// Setting the 1st bit -> +1
// ==> -255 :)
CL--;
}
Edited by Ufo-Pu55y
Link to comment
Sry, I dunno the delphi syntax, but couldn't a byte roling

simply being simulated like this ?

	int AL = 69			// or 16... take AL register
int CL = 48 // or 32... take CL register while (CL > 0)
{
AL ^= 1; // means SHL AL,1
if (AL > 255) // is the 9th bit set ? ...
AL -= 255; // .. then place it into the 1st one !
// Removing the 9th bit -> -256
// Setting the 1st bit -> +1
// ==> -255 :)
CL--;
}

I got new delphi lite (v3) and now it works, i did it how zako recomended, so i have not tested your algo.

Thanks m8's for helping me out!

Link to comment
AL ^= 1;
There was a bug anyway.. oops

AL <<= 1;

or

AL *= 2;

No problem, as i told earlier - i havent tryed it.

I think "<<=" is less or equal but i havent got a clue what is "*=" :(

I never tried any programing language that begins with a "c".. sorry.. :)

Regards, ChupaChu!

Link to comment

<< is in c for shl not rol.

and what a problem to code rol on al.

you can mix it with shl and shr.

8bit rol looks like it:

and define just i and j as unsigned char

return ((i << j) | (i >> (8 - j)));

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...