x86 assember code reversal

I have created a code function that I have attempted to reverse the effects of with no luck. It takes in a char (stored in ecx register) and a encryption key that is used (stored in al part of eax register). I have tried to reverse the code effects but the outputted result is never the same. I feel the xor is the main issue as how can you reverse an xor? I am trying to reverse the entire effects of the function, not each line individually. The part of the function that needs reversing is:

1
2
3
4
5
6
7
8
9
10
11
12
13
  			  ror al,1						// rotates the al part of the eax register (the Ekey) bitwise by 1 bit, as 1 mod 8 = 1 (al = 2D)
			  ror al,1						// moves the rightmost bit from al (the end of the Ekey) and shifts everything along
			  ror al,1						// rotates al bitwise by 1 bit, as 1 mod 8 = 1 (al = 4B)
			  ror al,1						// rotates the end 8 bits of the Ekey bitwise by 1 bit, as 1 mod 8 = 1 (al = A5)
			  push ecx						// preserves the value of the encrypted character by pushing it on the stack, the stack pointer decrements by 4 to allow this
			  not eax						// completes the ones' complement on the Ekey, toggling the bits
			  mov edx,eax					// copies the current value of the Ekey register and places it in edx, for holding
			  pop eax						// restores original register value from stack
			  xor eax,edx					// completes a bitwise exclusive or on the Ekey, with the previous value of the Ekey that was stored in edx
			  ror al,1						// rotates the last 8 bits of the Ekey bitwise by 1 bit, as 1 mod 8 = 1
			  ror al,1						// rotates al bitwise by 1 bit, as 1 mod 8 = 1
			  not eax						// completes the ones' complement on the Ekey value, 'flipping' eax entirely
			  add eax,0x20					// adds the hex value of 20 (32 in base 10) to the current value in the Ekey 
My currents attempts are below... neither of which works currently:

1
2
3
4
5
6
7
8
9
          sub eax, 0x20
          not eax
          rol al, 2
          xor ecx, eax
          push eax
          mov eax, edx
          not eax
          pop ecx
          rol al, 4


1
2
3
4
5
6
7
  sub eax, 0x20
  not eax
  rol al, 2
  ror al, 4
  not eax
  xor ecx, eax
Topic archived. No new replies allowed.