试图正确理解这个汇编代码

时间:2015-07-09 12:24:21

标签: c++ assembly encryption

__asm {
    encryptX:  push ecx             //push to manipulate
    xchg eax, ecx                   //exchange values in eax and ecx / eax holds old ecx 
    neg  al                         //divide least bit of eax by negative 1  (old ecx)
    ror  al, 1                      //rotate right least most bit by 1 of eax 
    xor  al, byte ptr[ecx]          //exlcusive or least most bit 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 bit by pointed value in eax
    rol  dl, 2                      //rotate left the least bit in edx by 2
    mov  eax, edx                   //move edx value into eax
    pop  edx                        //pop values out
    pop  ecx                        //pop values out
    ret                             //return
}

我认为我是正确的,大多数只是需要确认一些线 例如xor al, byte ptr[ecx]我理解它将xor eax寄存器中最少的一部分,但我不明白什么? byte ptr [ecx]是我感到困惑的地方。

0 个答案:

没有答案