Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,

Similar presentations


Presentation on theme: "1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,"— Presentation transcript:

1 1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization, ed-5 3. Materi kuliah CS61C/2000 & CS152/1997, UCB 4. Intel Architecture Software Developer’s Manual 17 Maret 2004 L. Yohanes Stefanus Bobby Nazief bahan kuliah:

2 2 Logical Instructions °The logical instructions AND, OR, XOR (exclusive or), and NOT perform the standard Boolean operations for which they are named. OF and CF flags are cleared; SF, ZF, and PF flags are set according to the result; AF flag is undefined (AND/OR/XOR) °The shift instructions rearrange the bits within an operand. CF flag contains the value of the last bit shifted out of the destination operand; it is undefined for SHL and SHR instructions where the count is greater than or equal to the size (in bits) of the destination operand. OF flag is affected only for 1-bit shifts; otherwise, it is undefined. SF, ZF, and PF flags are set according to the result. If the count is 0, the flags are not affected. For a non-zero count, the AF flag is undefined. °The rotate instructions rearrange the bits within an operand. CF flag contains the value of the bit shifted into it. OF flag is affected only for singlebit rotates; it is undefined for multi-bit rotates.

3 3 Logical Instructions: Summary 1.AND And 2.OR Or 3.XOR Exclusive or 4.NOT Not 5.SAR Shift arithmetic right 6.SHR Shift logical right 7.SAL/SHL Shift arithmetic left/Shift logical left 8.SHRD Shift right double 9.SHLD Shift left double 10.ROR Rotate right 11.ROL Rotate left 12.RCR Rotate through carry right 13.RCL Rotate through carry left

4 4 Format Instruksi AND (OR, XOR) ACC  [ACC]  IMM AND AL,imm8 AL AND imm8 AND AX,imm16 AX AND imm16 AND EAX,imm32 EAX AND imm32 REG/MEM  [REG/MEM]  IMM AND r/m8,imm8 r/m8 AND imm8 AND r/m16,imm16 r/m16 AND imm16 AND r/m32,imm32 r/m32 AND imm32 AND r/m16,imm8 r/m16 AND imm8 (sign-extended) AND r/m32,imm8 r/m32 AND imm8 (sign-extended) REG/MEM  [REG/MEM]  [REG] AND r/m8,r8 r/m8 AND r8 AND r/m16,r16 r/m16 AND r16 AND r/m32,r32 r/m32 AND r32 REG  [REG]  [REG/MEM] AND r8,r/m8 r8 AND r/m8 AND r16,r/m16 r16 AND r/m16 AND r32,r/m32 r32 AND r/m32

5 5 Format Instruksi NOT °NOT r/m8 Reverse each bit of r/m8 °NOT r/m16 Reverse each bit of r/m16 °NOT r/m32 Reverse each bit of r/m32 CONTOH: °NOT DL °NOT BYTE [DATA] °NOT DX °NOT WORD [DATA] °NOT EDX °NOT DWORD [DATA]

6 6 Shift Instructions °Shift Left SAL (shift arithmetic left) SAL SRC SAL SRC,COUNT SHL (shift logical left) SHL SRC SHL SRC,COUNT SHLD (shift left double) SHLD SRC,REG,COUNT °Shift Right SAR (shift arithmetic right) -lihat SAL SHR (shift logical right) -lihat SHL SHRD (shift right double) -lihat SHLD

7 7 SAL & SHL °shift the source operand left by from 1 to 31 bit positions °empty bit positions are cleared °CF flag is loaded with the last bit shifted out of the operand

8 8 SHR °shifts the source operand right by from 1 to 31 bit positions °empty bit positions are cleared °CF flag is loaded with the last bit shifted out of the operand

9 9 SAR °shifts the source operand right by from 1 to 31 bit positions °preserves the sign of the source operand by clearing empty bit positions if the operand is positive, or setting the empty bits if the operand is negative °CF flag is loaded with the last bit shifted out of the operand

10 10 Format Instruksi SAL (SAR, SHL, SHR) 1-OPERAND SAL r/m8 Multiply r/m8 by 2, 1 time SAL r/m16 Multiply r/m16 by 2, 1 time SAL r/m32 Multiply r/m32 by 2, 1 time 2-OPERAND w/ CL SAL r/m8,CL Multiply r/m8 by 2, CL times SAL r/m16,CL Multiply r/m16 by 2, CL times SAL r/m32,CL Multiply r/m32 by 2, CL times 2-OPERAND w/ IMM SAL r/m8,imm8 Multiply r/m8 by 2, imm8 times SAL r/m16,imm8 Multiply r/m16 by 2, imm8 times SAL r/m32,imm8 Multiply r/m32 by 2, imm8 times

11 11 SHLD & SHRD °shift a specified number of bits from one operand to another °provided to facilitate operations on unaligned bit strings or to implement a variety of bit string move operations

12 12 Format Instruksi SHLD (SHRD) °SHLD r/m16, r16, imm8 Shift r/m16 to left imm8 places while shifting bits from r16 in from the right °SHLD r/m16, r16, CL Shift r/m16 to left CL places while shifting bits from r16 in from the right °SHLD r/m32, r32, imm8 Shift r/m32 to left imm8 places while shifting bits from r32 in from the right °SHLD r/m32, r32, CL Shift r/m32 to left CL places while shifting bits from r32 in from the right

13 13 Rotate Instructions °Rotate Left ROL (rotate left) RCL (rotate through carry left) °Rotate Right ROR (rotate right) RCR (rotate through carry right) °Format R-OP SRC,COUNT

14 14 ROL & ROR °ROL instruction rotates the bits in the operand to the left (toward more significant bit locations) °ROR instruction rotates the operand right (toward less significant bit locations) °CF flag always contains the value of the last bit rotated out of the operand

15 15 RCL & RCR °RCL instruction rotates the bits in the operand to the left, through the CF flag) °RCR instruction rotates the bits in the operand to the right through the CF flag °CF flag always contains the value of the last bit rotated out of the operand

16 16 Format Instruksi RCL (RCR, ROL, ROR) °RCL r/m8, 1 Rotate 9 bits (CF, r/m8) left once °RCL r/m8, CL Rotate 9 bits (CF, r/m8) left CL times °RCL r/m8, imm8 Rotate 9 bits (CF, r/m8) left imm8 times °RCL r/m16, 1 Rotate 17 bits (CF, r/m16) left once °RCL r/m16, CL Rotate 17 bits (CF, r/m16) left CL times °RCL r/m16, imm8 Rotate 17 bits (CF, r/m16) left imm8 times °RCL r/m32, 1 Rotate 33 bits (CF, r/m32) left once °RCL r/m32, CL Rotate 33 bits (CF, r/m32) left CL times °RCL r/m32,i mm8 Rotate 33 bits (CF, r/m32) left imm8 times


Download ppt "1 IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations Sumber: 1. Paul Carter, PC Assembly Language 2. Hamacher. Computer Organization,"

Similar presentations


Ads by Google