有没有什么教程可以解释汇编语言中可能存在的所有复杂的布尔逻辑运算?例如,我不知道下面的汇编代码块是做什么的:
mov [ebp-8h], 31982853h
mov eax, [ebp+Ch]
shl eax, 8
mov ecx, [ebp+Ch]
shr ecx, 8
or eax, ecx
我理解shl、shr和or指令的作用,但对它们的组合结果一无所知。有没有人能给我介绍一下彻底解释汇编语言中布尔逻辑运算的教程?
谢谢。
发布于 2012-01-18 02:38:15
带注释的代码:
mov eax, [ebp+Ch] ; grab our 32-bit value
shl eax, 8 ; shift it left 8 bits, so the top 8 bits are shifted out
; and the bottom 8 bits are filled w/ 0
mov ecx, [ebp+Ch] ; grab our 32-bit value again
shr ecx, 8 ; shift this copy right 8 bits, so the bottom 8 bits are
; shifted out and the top 8 bits are filled w/ 0
or eax, ecx ; perform A = A or C for each set of same-aligned bits in
; EAX (A) and ECX (C)
因此,如果原始值是ABCD (每个字母是一个8位字节),那么在执行or之前,EAX的值应该是BCD0,ECX的值应该是0ABC。
发布于 2012-01-18 03:29:37
如果[ebp+Ch]
处的变量包含16位的值(即只有16个最低有效位可以不为零),那么这段代码将有效地交换其字节(0到7位与8到15位)。但是,or eax, ecx
之后的eax
中的结果必须用0FFFFh进行掩码(and
'ed),除非后面的代码使用ax
而不是eax
。
https://stackoverflow.com/questions/8899420
复制相似问题