120 likes | 357 Views
Chapter Four 80x86 Instruction Set ( 5 ). Logical, Shift, Rotate Instructions. The 80x86 family provides--- five logical instructions: and, or, xor, test, and not ; four rotate instructions: ror, rol, rcr, and rcl ; three shift instructions. shl/sal, shr, and sar.
E N D
Chapter Four80x86 Instruction Set(5) 2014年10月20日1
Logical, Shift, Rotate Instructions • The 80x86 family provides--- • five logical instructions: and, or, xor, test, and not; • four rotate instructions: ror, rol, rcr, and rcl; • three shift instructions. shl/sal, shr, and sar. 2014年10月20日2
The Logical Instructions: AND, TEST,OR, XOR, and NOT • and dest, source ;dest := dest and source • testdest, source ; dest and source • or dest, source ;dest := dest or source • xor dest, source ;dest := dest xor source • not dest ;dest := not dest 2014年10月20日3
The Shift Instructions: SHL/SAL, SHR, SAR • The 80x86 supports three different shift instructions (shl and sal are the same instruction): • shl (shift left), • sal (shift arithmetic left), • shr (shift right), • sar (shift arithmetic right). • The 80386 and later processors provide two additional shifts: shld and shrd. 2014年10月20日4
The Shift Instructions: SHL/SAL, SHR, SAR • The shift instructions move bits around in a register or memory location. The general format for a shift instruction is • shl dest, count • sal dest, count • shr dest, count • sar dest, count 2014年10月20日5
The Shift Instructions: SHL/SAL, SHR, SAR • shl reg, 1 • shl mem, 1 • shl reg, cl • shl mem, cl • sal is a synonym for shl and uses the same formats. • shr uses the same formats as shl. • sar uses the same formats as shl. 2014年10月20日6
The Shift Instructions: SHL/SAL, SHR, SAR 2014年10月20日7
The Rotate Instructions: RCL, RCR, ROL, and ROR The rotate instructions shift the bits around, just like the shift instructions, except the bits shifted out of the operand by the rotate instructions recirculate through the operand. They include rcl (rotate through carry left), rcr (rotate through carry right), rol (rotate left), and ror (rotate right). These instructions all take the forms: rcl reg, 1 rcl mem, 1 rcl reg, cl rcl mem, cl 2014年10月20日8
RCL 2014年10月20日9
RCR 2014年10月20日10
ROL 2014年10月20日11
ROR 2014年10月20日12