cdecl和std调用 - 如何使我的代码变得常规

时间:2015-07-12 10:15:48

标签: c++ x86 stdcall cdecl

__asm {                         //
        push   eax                  //
            push   ecx              //
            movsx  ecx, temp_char   //
            lea    eax, EKey        //
            call   encryptX         // encrypt the character
            mov    temp_char, al    //
            pop    ecx              //
            pop    eax              //
    }
    EChars[i] = temp_char;          // Store encrypted char in the encrypted chars array
}
return;

// ---------------------------- start of ASM code ---------------------------------------------------------------encryptX:  push ecx                    //push to manipulate
    xchg eax, ecx                   //exchange values in eax and ecx / eax holds old ecx 
    neg  al                         //twos complement least most eax byte (old ecx)
    ror  al, 1                      //rotate right least most byte by 1 of eax 
    xor  al, byte ptr[ecx]          //exlcusive or least most byte against ecx value being pointed at
    push edx                        //push edx onto stack for manipulatio
    mov  edx, eax                   //move eax into edx
    xchg eax, ecx                   //swap values of ecx and eax
    rol  byte ptr[eax], 3           //rotate left the byte being pointed at 3 times
    xor  dl, byte ptr[eax]          //xor the least byte by pointed value in eax
    rol  dl, 2                      //rotate left the least byte in edx by 2
    mov  eax, edx                   //move edx value into eax
    pop  edx                        //pop values out
    pop  ecx                        //pop values out
    ret                             //return
}

我的任务是在此代码中实现标准调用 - 即cdecl或std调用

' mov eax,[ebp + 8] //获取第一个被推送的参数'

我理解推动指针位置的想法,但我不确定我会告诉指针的位置。

是mov eax,[ebp + 4/8/12]还是你有什么

任何有助于告诉我如何做到这一点的帮助将不胜感激,同样如果你们其中一个善良的人解决了这个问题,可以添加一个解释

由于

0 个答案:

没有答案