samedi 25 avril 2015

Converting this C++ for loop into assembly language


I am having trouble understanding how I would convert a couple of lines of code from my simple encryption program into assembly language, mainly the FOR loop. Could anyone give me any pointers on how to achieve this? I understand I can create a breakpoint and look at it in asm when it is running but it points to specific memory locations and such, and I am wondering how I would write it myself.

This is part of my program including the lines I need to convert into assembly.

void encrypt_chars(int length, char EKey)   // Encryption Function.

{
char temp_char;                         // Char temporary store.    
for (int i = 0; i < length; i++)        // Encrypt characters one at a time.
{
    temp_char = OChars[i];              // Orignal Chars.

    __asm {                                 // Switch to inline assembly.

            push   eax                  
            push   ecx                  

            movzx  ecx, temp_char       
            push   ecx                  
            lea    eax, EKey            
            push   eax                  
            call   encrypt4             
            add    esp, 8               
            mov    temp_char, al        

            pop    ecx                  
            pop    eax          

      EChars[i] = temp_char;                
}
return;

Thank you.


Aucun commentaire:

Enregistrer un commentaire