Q:

x86 assembly language decryption

the first bit of the code is the encryption bi, this encrypts a six  character word and it works as it should.
push ebp
mov ebp,esp

push edx
push ecx 
push eax

movzx eax,byte ptr [eax] 

rol al,1 
rol al,1 
rol al,1

mov edx,eax 
pop eax 
mov byte ptr [eax],dl
pop ecx 

xor ecx,edx 
mov eax,ecx 

ror al,1 
ror al,1 
ror al,1 

pop edx 
pop ebp

the second bit of code is meant to be the decryption bit which i have altered however doesn't work as it should. for example if the encrypted word was "goal" the de-crypted word i would get back would be "yoxl", note the second and last letters are correct but the first and third are different. can anyone show me where am going wrong or at least in the right direction please ?
push ebp
mov ebp,esp

push edx // Push values of the edxregister onto stack
push ecx // push the characters onto the stack so that they can be returned
push eax// push the address of the ekey onto the stack

movzx eax,byte ptr [eax] // set eax to the  8- bit value in memory that eax is pointing at - eax holds the value of the key

mov edx,eax // move the ekey into the edx register
pop eax // return the  address of the  ekey from the stack into eax
mov byte ptr [eax],dl
pop ecx // restore the character from the stack

rol al,3

mov eax,ecx // move the address of the encrypted character into the eax register    

rol al,3

xor eax,edx 

pop edx // restore to original values form the stack into EDX
pop ebp

ret

A:

The first thing I spot is your second rotation in the decryption function:
rol al,3

This should probably be:
ror al, 3

The second thing is the xor:
xor eax,edx

which should probably be moved to before the second rotation and mov, and also change the register that is xored:
xor ecx,edx
mov eax,ecx
ror al,3

To summarize the decryption:
push ebp
mov ebp,esp

push edx
push ecx
push eax

movzx eax,byte ptr [eax]    
mov edx,eax
pop eax
mov byte ptr [eax],dl
pop ecx

rol al,3

xor ecx,edx 
mov eax,ecx

ror al,3

pop edx
pop ebp

ret

Edit
Your encryption order is: rol, xor, ror
This yields the decryption order: rol, xor, ror
In fact you should be able to run the encryption routine twice and it would yield the original input (plaintext).

