Convert into a procedure

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2008
Posts: 1
Reputation: BujarM is an unknown quantity at this point 
Solved Threads: 0
BujarM BujarM is offline Offline
Newbie Poster

Convert into a procedure

 
0
  #1
Nov 29th, 2008
IN CPP:
  1. extern "C" {
  2. void ENCRYPT_CPP(char buffer,int count, char CIPHER,int CIPHER_LENGTH);

  1. void ENCRYPT_CPP(char buffer[],int count,char CIPHER[],int CIPHER_LENGTH )
  2. {
  3. int t=0;
  4. for( int i=0; i<count; i++)
  5. {
  6. buffer[i]=buffer[i] ^ CIPHER[t % CIPHER_LENGTH];
  7. t++;
  8. }
  9.  
  10. }
Im having trouble converting this cpp function into an ASM procedure. The closest code i got near to a procedure was
  1. mov ecx,LENGTHOF buffer
  2. mov esi,0
  3. mov edi,0
  4. L1:
  5. mov eax,esi
  6. CDQ
  7. mov ebx,CIPHER_LENGTH
  8. IDIV ebx
  9. mov edi,edx
  10. mov eax,0
  11. mov eax,DWORD PTR CIPHER[edi]
  12. mov ebx,0
  13. mov ebx, DWORD PTR buffer[esi]
  14. xor eax, ebx
  15. mov buffer[esi],al
  16. inc esi
  17. loop L1

Help plz
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 5,850
Reputation: Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute Salem has a reputation beyond repute 
Solved Threads: 751
Team Colleague
Salem's Avatar
Salem Salem is offline Offline
Void main'ers are DOOMed

Re: Convert into a procedure

 
0
  #2
Nov 29th, 2008
> 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?
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Assembly Forum
Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC