rotate_instructions

50 %
50 %
Information about rotate_instructions
Education

Published on March 23, 2014

Author: yuri56

Source: slideshare.net

* Property of STI Page 1 of 14 Rotate Instruction Computer Organization and Assembly Language Rotate Instructions  rotate bits out into the other end of the operand  can be classified by the direction of the rotation (rotate to the left or rotate to the right) 1 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 3 of 14 Rotate Instruction Computer Organization and Assembly Language The ROL Instruction  The ROL (Rotate Left) instruction rotates to the left the destination operand by the number of bits specified in the count operand.  Format: ROL D, Count  Action: CF Operand Destination Example register ROL AL, CL MM ROL byte ptr BETA, CL register ROL AL, 1 MM ROL byte ptr BETA, 1 3 __________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 2 of 14 Rotate Instruction Computer Organization and Assembly Language Rotate Instructions  The different types of rotate instructions are:  ROL instruction  ROR instruction  RCL instruction  RCR instruction 2 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 4 of 14 Rotate Instruction Computer Organization and Assembly Language Example - ROL Instruction Example 1: MOV AL, 04H ROL AL, 1 After execution, AL = 08H. The flags will be: CF = 0, OF = 0 Example 2: MOV AL, 55H MOV CL, 03H ROL AL, CL After execution, AL = AAH. The flags will be: CF = 0; OF = undefined 4 __________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________

* Property of STI Page 5 of 14 Rotate Instruction Computer Organization and Assembly Language The ROR Instruction  The ROR (Rotate Right) instruction rotates to the right the destination operand by the number of bits specified in the count operand.  Format: ROR D, Count  Action: CFOperand ROR byte ptr BETA, 1MM ROR AL, 1register ROR byte ptr BETA, CLMM ROR AL, CLregister ExampleDestination 5 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 7 of 14 Rotate Instruction Computer Organization and Assembly Language Exercise  Execute the following instructions. Assume that each instruction is dependent of one another. Assume that all flags are initially zero. MOV AL, 5EH MOV CL, 02H ROR AL, CL ROL AL, CL 7 __________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 6 of 14 Rotate Instruction Computer Organization and Assembly Language Example - ROR Instruction Example 1: MOV AL, 04H ROR AL, 1 After execution, AL = 02H. The flags will be: CF = 0, OF = 0 Example 2: MOV AL, 55H MOV CL, 03H ROR AL, CL After execution, AL = AAH. The flags will be: CF = 0; OF = undefined 6 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 8 of 14 Rotate Instruction Computer Organization and Assembly Language The RCL Instruction  The RCL (Rotate Left through Carry) instruction rotates to the left the destination operand by the number of bits specified in the count operand. The carry flag is treated as part of the rotate.  Format: RCL D, Count  Action: CF Operand RCL byte ptr BETA, 1MM RCL AL, 1register RCL byte ptr BETA, CLMM RCL AL, CLregister ExampleDestination 8 __________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________

* Property of STI Page 9 of 14 Rotate Instruction Computer Organization and Assembly Language Example - RCL Instruction Example 1: MOV AL, 04H RCL AL, 1 Assume that CF = 1. After execution, AL = 09H. The flags will be: CF = 0, OF = 0 Example 2: MOV AL, 55H MOV CL, 03H RCL AL, CL Assume CF = 0. After execution, AL = A9H. The flags will be: CF = 0; OF = undefined 9 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 11 of 14 Rotate Instruction Computer Organization and Assembly Language Example – RCR Instruction Example 1: MOV AL, 04H RCR AL, 1 Assume that CF = 1. After execution, AL = 82H. The flags will be: CF = 0, OF = 1 Example 1: MOV AL, 55H MOV CL, 03H RCR AL, CL Assume CF = 0. After execution, AL = 4AH. The flags will be: CF = 1; OF = undefined 11 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 10 of 14 Rotate Instruction Computer Organization and Assembly Language The RCR Instruction  The RCR (Rotate Right through Carry) instruction rotates to the right the destination operand by the number of bits specified in the count operand. The carry flag is treated as part of the rotate.  Format: RCR D, Count  Action: CFOperand RCR byte ptr BETA, 1MM RCR AL, 1register RCR byte ptr BETA, CLMM RCR AL, CLregister ExampleDestination 10 ________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 12 of 14 Rotate Instruction Computer Organization and Assembly Language Quiz – Rotate Instructions  Execute the following instructions. Assume that each instruction is dependent of one another. Determine the status of the flags. MOV AL, 7EH MOV CL, 02H ROR AL, CL RCR AL, CL RCL AL, CL ROL AL, CL 12 _________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________

* Property of STI Page 13 of 14 Rotate Instruction Computer Organization and Assembly Language Program Tracing Example  Perform the indicated operation. Each instruction is dependent of one another. Whenever necessary, use the memory map (handout) for additional data. Assume the following register contents and assume that all flags are initially 0: MOV DX, FFFEH XOR SI, SI XCHG DX, SI DEC CX RCR word ptr [SI], CL MOV BX, [SI] MOV CX, 0009H ROL BX, CL AX = 0015H BP = 0002H CS = 3000H BX = 0019H SP = 0035H DS = 2000H CX = 0012H DI = 0017H SS = 2000H DX = 001BH SI = 001EH ES = 4000H 13 ________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ * Property of STI Page 14 of 14 Rotate Instruction Computer Organization and Assembly Language Program Tracing Exercise  Unless otherwise stated, determine the contents of all the affected general-purpose registers and the flags after executing the following programs (assume that all registers and flags are initially 0): MOV DX, DB53H ROR DX, 01H RCR DX, 01H ROL DH, 01H ROL DL, 01H RCL DX, 01H RCR DX, 01H What will be DX after executing? 14 ________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________ ___________________

Add a comment

Related presentations

Related pages

Shift and Rotate Instructions in Assembly Language

Assembly Language shift and rotate instructions summary. This web page examines shift and rotate instructions in assembly language. Specific examples of ...
Read more

Rotate Instructions (IA-32 Assembly Language Reference Manual)

Documentation Home > IA-32 Assembly Language Reference Manual > Chapter 2 Instruction-Set Mapping > Rotate Instructions.
Read more

Logic, Shift, and Rotate Instructions - ICS 491

Logic, Shift, and Rotate Instructions can be used to change the bit values in an operand. The ability to manipulate bit values is generally absent in high ...
Read more

Logic, Shift, and Rotate Instructions - Sam Houston State ...

Logic, Shift, and Rotate Instructions CS 272 Sam Houston State University Dr. Tim McGuire Boolean Data. 0 or 1; Requires only a single bit; 0 = FALSE; 1 = TRUE
Read more

assembly - What's the purpose of the rotate instructions ...

I always wondered what's the purpose of the rotate instructions some CPUs have (ROL, RCL on x86, for example). What kind of software makes use of these ...
Read more

Shift and Rotate Instructions (x86 Assembly Language ...

Shift and Rotate Instructions. The shift and rotate instructions shift and rotate the bits in their operands. Table 3–5 Shift and Rotate Instructions.
Read more

Chapter 7 - Logical, Shift and Rotate Instructions

Introduction Shift and Rotate Instructions Logical Instructions Example Programs Chapter 7 - Logical, Shift and Rotate Instructions February 23, 2007
Read more

EdSim51 - Notes on the 8051

The 8051 Simulator for Lecturers and Students. ... The Accumulator as a Shift and a Rotate Register : As we shall see, the ability to use the accumulator ...
Read more

x64 Assembly and C++ Tutorial 17: Rotate Instructions ...

In this, the 17th, tutorial we'll be going through four rotate instructions, ROR, ROL, RCR and RCL. These instructions perform a related ...
Read more

C Programming Tutorial: shift/rotate instructions

The next lot of instructions to cover are the shift and rotate instructions. To the person unfamiliar with assembly language, instructions such as these ...
Read more