0

IN CPP:

extern "C" {
 void ENCRYPT_CPP(char buffer,int count, char CIPHER,int CIPHER_LENGTH);
void ENCRYPT_CPP(char buffer[],int count,char CIPHER[],int CIPHER_LENGTH )
{
	int t=0;
	for( int i=0; i<count; i++)
	{
		buffer[i]=buffer[i] ^ CIPHER[t % CIPHER_LENGTH];
	t++;
	}
	
}

Im having trouble converting this cpp function into an ASM procedure. The closest code i got near to a procedure was

mov ecx,LENGTHOF buffer
  mov esi,0
  mov edi,0
  L1:
  mov eax,esi
  CDQ
  mov ebx,CIPHER_LENGTH  
  IDIV ebx 
  mov edi,edx
  mov eax,0
  mov eax,DWORD PTR CIPHER[edi]
  mov ebx,0
  mov ebx, DWORD PTR buffer[esi]
  xor eax, ebx
  mov buffer[esi],al
  inc esi  
  loop L1

Help plz

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by Salem
0

> IDIV ebx
does this leave the result you want in esi?

> DWORD PTR CIPHER[edi]
It's a char array, not an array of dwords.

You're processing 4* as much data as you expect.

also
xor al,bl
etc, for bytes.

> void ENCRYPT_CPP(char buffer,int count, char CIPHER,int CIPHER_LENGTH);
Missing [ ] on buffer is copy/paste?
Or just what you typed?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.