1 / 16

IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations

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

Download Presentation

IKI10230 Pengantar Organisasi Komputer Kuliah no. 05.c: Logical Operations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IKI10230Pengantar Organisasi KomputerKuliah no. 05.c: Logical Operations Sumber:1. Paul Carter, PC Assembly Language2. Hamacher. Computer Organization, ed-53. Materi kuliah CS61C/2000 & CS152/1997, UCB4. Intel Architecture Software Developer’s Manual 17 Maret 2004 L. Yohanes Stefanus (yohanes@cs.ui.ac.id)Bobby Nazief (nazief@cs.ui.ac.id) bahan kuliah: http://www.cs.ui.ac.id/kuliah/POK/

  2. Logical Instructions • The logical instructions AND, OR, XOR (exclusive or), and NOT perform the standard Booleanoperations 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 undefinedfor 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 thecount 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 singlebitrotates; it is undefined for multi-bit rotates.

  3. Logical Instructions: Summary • AND And • OR Or • XOR Exclusive or • NOT Not • SAR Shift arithmetic right • SHR Shift logical right • SAL/SHL Shift arithmetic left/Shift logical left • SHRD Shift right double • SHLD Shift left double • ROR Rotate right • ROL Rotate left • RCR Rotate through carry right • RCL Rotate through carry left

  4. Format Instruksi AND (OR, XOR) ACC  [ACC]  IMM • AND AL,imm8AL AND imm8 • AND AX,imm16AX AND imm16 • AND EAX,imm32EAX AND imm32 REG/MEM  [REG/MEM]  IMM • AND r/m8,imm8r/m8 AND imm8 • AND r/m16,imm16r/m16 AND imm16 • AND r/m32,imm32r/m32 AND imm32 • AND r/m16,imm8r/m16 AND imm8 (sign-extended) • AND r/m32,imm8r/m32 AND imm8 (sign-extended) REG/MEM  [REG/MEM]  [REG] • AND r/m8,r8r/m8 AND r8 • AND r/m16,r16r/m16 AND r16 • AND r/m32,r32r/m32 AND r32 REG  [REG]  [REG/MEM] • AND r8,r/m8r8 AND r/m8 • AND r16,r/m16r16 AND r/m16 • AND r32,r/m32r32 AND r/m32

  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. 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 (shiftlogical right) • lihat SHL • SHRD (shift right double) • lihat SHLD

  7. SAL & SHL • shift thesource operand left by from 1 to 31 bit positions • empty bit positions are cleared • CF flagis loaded with the last bit shifted out of the operand

  8. SHR • shifts the source operand right by from 1 to 31 bit positions • empty bit positionsare cleared • CF flag isloaded with the last bit shifted out of the operand

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

  10. Format Instruksi SAL (SAR, SHL, SHR) 1-OPERAND • SAL r/m8Multiply r/m8 by 2, 1 time • SAL r/m16Multiply r/m16 by 2, 1 time • SAL r/m32Multiply r/m32 by 2, 1 time 2-OPERAND w/ CL • SAL r/m8,CLMultiply r/m8 by 2, CL times • SAL r/m16,CLMultiply r/m16 by 2, CL times • SAL r/m32,CLMultiply r/m32 by 2, CL times 2-OPERAND w/ IMM • SAL r/m8,imm8Multiply r/m8 by 2, imm8 times • SAL r/m16,imm8Multiply r/m16 by 2, imm8 times • SAL r/m32,imm8Multiply r/m32 by 2, imm8 times

  11. SHLD & SHRD • shift a specifiednumber of bits from one operand to another • provided to facilitateoperations on unaligned bit strings or to implement a variety of bit stringmove operations

  12. Format Instruksi SHLD (SHRD) • SHLD r/m16, r16, imm8Shift r/m16 to left imm8 placeswhile shifting bits from r16infrom the right • SHLD r/m16, r16, CLShift r/m16 to left CL places whileshifting bits from r16 infrom theright • SHLD r/m32, r32, imm8Shift r/m32 to left imm8 placeswhile shifting bits from r32infrom the right • SHLD r/m32, r32, CLShift r/m32 to left CL places whileshifting bits from r32 infrom theright

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

  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 ofthe operand

  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 ofthe operand

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

More Related