{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Ch 7 8 9 Slides_10 - CmpE 102 Chapter 7 Master subtitle...

Info icon This preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style 9/8/10 Irvine, Kip R. Assembly Language for Intel-Based CmpE 102 Chapter 7, 8 & 9 Slides Frank Cirimele 11
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 22
Image of page 2
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 33 Logical vs Arithmetic Shifts A logical shift fills the newly created bit position with zero: An arithmetic shift fills the newly created bit position with a copy of the number’s sign bit: CF 0 CF
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 44 SHL Instruction The SHL (shift left) instruction performs a logical left shift on the destination operand, filling the lowest bit with 0 . CF 0 Operand types for SHL: SHL reg,imm8 SHL mem,imm8 SHL reg ,CL SHL mem ,CL (Same for all shift and rotate instructions)
Image of page 4
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 55 Fast Multiplication mov dl,5 shl dl,1 Shifting left 1 bit multiplies a number by 2 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 = 5 = 1 0 B e fo re : A fte r: mov dl,5 shl dl,2 ; DL = 20 Shifting left n bits multiplies the operand by 2 n For example, 5 * 22 = 20
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 66 SHR Instruction The SHR (shift right) instruction performs a logical right shift on the destination operand. The highest bit position is filled with a zero. CF 0 mov dl,80 shr dl,1 ; DL = 40 shr dl,2 ; DL = 10 Shifting right n bits divides the operand by 2 n
Image of page 6
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 77 SAL and SAR Instructions SAL (shift arithmetic left) is identical to SHL. SAR (shift arithmetic right) performs a right arithmetic shift on the destination operand. CF An arithmetic shift preserves the number's sign. mov dl,-80 sar dl,1 ; DL = -40 sar dl,2 ; DL = -10
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 88 ROL Instruction ROL (rotate) shifts each bit to the left The highest bit is copied into both the Carry flag and into the lowest bit No bits are lost CF mov al,11110000b rol al,1 ; AL = 11100001b mov dl,3Fh rol dl,4 ; DL = F3h
Image of page 8
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 99 ROR Instruction ROR (rotate right) shifts each bit to the right The lowest bit is copied into both the Carry flag and into the highest bit CF mov al,11110000b ror al,1 ; AL = 01111000b mov dl,3Fh ror dl,4 ; DL = F3h
Image of page 9

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 1010 RCL Instruction RCL (rotate carry left) shifts each bit to the left Copies the Carry flag to the least significant bit CF clc ; CF = 0 mov bl,88h ; CF,BL = 0 10001000b rcl bl,1 ; CF,BL = 1 00010000b rcl bl,1 ; CF,BL = 0 00100001b
Image of page 10
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 1111 RCR Instruction RCR (rotate carry right) shifts each bit to the right Copies the Carry flag to the most significant bit stc ; CF = 1 mov ah,10h ; CF,AH = 1 00010000b rcr ah,1 ; CF,AH = 0 10001000b CF
Image of page 11

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
9/8/10 Irvine, Kip R. Assembly Language for Intel-Based 1212 Application: Shifting Multiple Doublewords Programs sometimes need to shift all bits within an array, as one might when moving a bitmapped graphic image from one screen location to another.
Image of page 12
Image of page 13
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern