Converting this C++ for loop into assembly language -


basically trying convert block of c++ & assembly purely assembly, bit confused how conver loop , rest assembly, if let me know going wrong great.

this original

void encrypt_chars (int length, char ekey)      // encryption function.  {   char temp_char;                     // char temporary store.  (int = 0; < length; i++)    // encrypt characters 1 @ time. {     temp_char = ochars [i];         // orignal chars.      __asm {                         // switch inline assembly.          push   eax                           push   ecx                            movzx  ecx,temp_char                 push   ecx                           lea    eax,ekey                      push   eax                           call   encrypt4             // call encryption subroutine          add    esp, 8                         mov    temp_char,al                   pop    ecx                           pop    eax                       }     echars [i] = temp_char;         // store encrypted char in encrypted chars array. } return; 

then attempt @ convering c++ parts assembly stuggling , appreciate pointers -

void encrypt_chars(int lengths, char ekey)  // encryption function.  {     char temp_char;      __asm {      mov         dword ptr[i], 0     jmp         encrypt_chars     mov         eax, dword ptr[i]     add         eax, 1     mov         dword ptr[i], eax     mov         eax, dword ptr[i]     cmp         eax, dword ptr[lengths]     jge         encrypt_chars       mov         eax, dword ptr[i]     mov         cl, byte ptr[eax]     mov         byte ptr[temp_char], cl      push   eax                       push   ecx                        movzx  ecx,temp_char             push   ecx                       lea    eax,ekey                  push   eax                       call   encrypt4             // call encryption subroutine      add    esp, 8                     mov    temp_char,al               pop    ecx                       pop    eax                         mov         eax, dword ptr[i]     mov         cl, byte ptr[temp_char]     mov         byte ptr[eax], cl  } return; 

here assembly example of loop:

mov r1, #5  ; limit of loop mov r0, #0  ; r0 loop index, initialize loop index variable. loop:   cmp r0, r1 ; part of compare expression in loop.   bge loop_exit; ; ;  statement block for loop.   inc r0   ; increment part of loop   b   loop ; loop around compare part of loop.  ; first statement after loop loop_exit: 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -