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

> 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?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.