MGMT 1030 Lecture Notes - Lecture 21: Arithmetic Shift, Instruction Set, Logical Shift

11 views2 pages
MGMT 1030 Lecture 21 Notes CPU Instruction
Introduction
Shifts and rotate operations have other programming applications, and CPU instruction
sets commonly provide a variety of different shift and rotate instructions for the
programmer to use.
As shown, shift instructions move the data bits left or right one or more bits.
Rotate instructions also shift the data bits left or right, but the bit that is shifted out of
the end is placed into the vacated space at the other end.
Depending on the design of the particular instruction set, bits shifted out the end of the
word may be shifted into a different register or into the carry or overflow flag bit.
They ay siply fall off the ed ad e lost.
Two different kinds of shifts are usually provided.
The data word being shifted might be logical or it might be numeric.
Logical shift instructions simply shift the data as you would expect, and zeros are shifted
in to replace the bit spaces that have been vacated.
Arithmetic shift instructions are commonly used to multiply or divide the original value
by a power of 2.
Therefore, the instruction does not shift the leftmost bit, since that bit usually
represents the algebraic sign of the numeric value
Obviously the sign of a number must be maintained.
Left arithmetic shifts do not shift the left bit, but zeros replace the bits from the right as
bits are moved to the left.
These will effectively double the numeric value for each shift of one bit.
On the other hand, right arithmetic shifts fill the space of moved bits with the sign bit
rather than with zero.
This has the effect of halving the value for each bit shifted, while maintaining the sign of
the value.
It may not seem obvious to you that this works correctly
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 2 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents