SHL、SHR、SAL、SAR: 移位指令 ;SHL(Shift Left): 逻辑左移 ;SHR(Shift Right): 逻辑右移 ;SAL(Shift Arithmetic Left): 算术左移 ;SAR(Shift Arithmetic Right): 算术右移 ;其中的 SHL 和 SAL 相同, 但 SHR 和 SAR 不同. ;SHL、SAL: 每位左移, 低位补 0, 高位进 CF ;SHR : 每位右移, 低位进 CF, 高位补 0 ;SAR : 每位右移, 低位进 CF, 高位不变 ;它们的结果影响 OF、SF、ZF、PF、CF ;它们的指令格式相同: SHL r/m, i8 SHL r/m, CL ; Test24_1.asm .386 .model flat, stdcall include Windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc ;SHL、AL mov al, 11100111b shl al, 1 PrintHex al ;CE - 11001110b sal al, 2 PrintHex al ;38 - 00111000b mov al, 11100111b mov cl, 2 shl al, cl PrintHex al ;9C - 10011100b ;SHR mov al, 11100111b shr al, 2 PrintHex al ;39 - 00111001b ;SAR mov al, 11100111b sar al, 2 PrintHex al ;F9 - 11111001b ret main endp end main
ROL、ROR、RCL、RCR: 循环移位指令 ;ROL(Rotate Left): 循环左移 ;ROR(Rotate Right): 循环右移 ;RCL(Rotate through Carry Left): 带进位循环左移 ;RCR(Rotate through Carry Right): 带进位循环右移 ;ROL: 循环左移, 高位到低位并送 CF ;ROR: 循环右移, 低位到高位并送 CF ;RCL: 循环左移, 进位值(原CF)到低位, 高位进 CF ;RCR: 循环右移, 进位值(原CF)到高位, 低位进 CF ;它们的结果影响 OF、CF ;它们的指令格式相同: SHL r/m, i8 SHL r/m, CL ; Test24_2.asm .386 .model flat, stdcall include Windows.inc include kernel32.inc include masm32.inc include debug.inc includelib kernel32.lib includelib masm32.lib includelib debug.lib .code main proc ;ROL mov al, 11000011b rol al, 1 PrintHex al ;87 - 010000111b ;ROR mov al, 11000011b ror al, 1 PrintHex al ;E1 - 11100001b ;RCL clc mov al, 10101111b rcl al, 1 PrintHex al ;5E - 01011110b stc mov al, 10101111b rcl al, 1 PrintHex al ;5F - 01011111b clc mov al, 10101111b rcl al, 2 PrintHex al ;BD - 10111101b ;RCR clc mov al, 11101011b rcr al, 2 PrintHex al ;BA - 10111010b ret main endp end main (责任编辑:admin)
|