mov al, 100d ; 01100100
shr eax, 1 ; cf = 0
; 00110010
如何在第5个位置刻录cf?
例如: 我的号码10000111。CF = 1 => 10001111
我的主要任务是使用shr(shl)制作反向字节。我想自己做,但不知道如何设置位
最佳答案
要反转位,只需将它们从源操作数移出的同一端移入目标操作数(即使用相反的移位)。示例代码:
mov al, 100 ; input = 01100100
mov ah, 0 ; output
mov ecx, 8 ; 8 bits to process
next:
shr al, 1 ; shift next bit out to the right
rcl ah, 1 ; shift it in from the right
loop next
; result in ah = 38 = 0010 1100
尽管如此,要回答您的问题:将进位移入归零的临时寄存器到给定位置,然后使用按位OR
将其设置到目的地。示例代码:
mov dl, 0 ; zero temp register, without affecting CF
rcl dl, 5 ; move CF into bit #5 (use CL register for dynamic)
or al, dl ; merge into al
关于assembly - 如何将钻头设置到位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25853309/