Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 正在尝试正确理解此汇编代码_C++_Assembly_Encryption - Fatal编程技术网

C++ 正在尝试正确理解此汇编代码

C++ 正在尝试正确理解此汇编代码,c++,assembly,encryption,C++,Assembly,Encryption,我想我大部分都是对的,只是需要用几行字来确认一下 例如,xor al,byte ptr[ecx]我知道它将对eax寄存器的最低位进行异或运算,但我不知道是什么原因造成的?字节ptr[ecx]是我感到困惑的地方。字节ptr[ecx]表示寄存器ecx中包含的地址处内存中的字节,即使您已经得到了答案,也应该写下您正在使用的汇编语言和汇编程序。这将有助于未来读者的理解(他们可能正在寻求答案)。好的,谢谢你,你能说我的其他评论是解释性的,而不仅仅是显而易见的吗?(bar-pop是pop)当你发布这段代码时

我想我大部分都是对的,只是需要用几行字来确认一下
例如,
xor al,byte ptr[ecx]
我知道它将对eax寄存器的最低位进行异或运算,但我不知道是什么原因造成的?字节ptr[ecx]是我感到困惑的地方。

字节ptr[ecx]
表示寄存器
ecx
中包含的地址处内存中的字节,即使您已经得到了答案,也应该写下您正在使用的汇编语言和汇编程序。这将有助于未来读者的理解(他们可能正在寻求答案)。好的,谢谢你,你能说我的其他评论是解释性的,而不仅仅是显而易见的吗?(bar-pop是pop)当你发布这段代码时表示(或应该表示)“最低有效位”而不知道位和字节之间的区别时,说“最低有效位”会让人感到困惑。:)
__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
}