Preview

corlang

Good Essays
Open Document
Open Document
386 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
corlang
Joven P. Alegria
Cs/act 221

Shift Instruction
Shifts the bits in the first operand (destination operand) to the left or right by the number of bits specified in the second operand (count operand). Bits shifted beyond the destination operand boundary are first shifted into the CF flag, then discarded. At the end of the shift operation, the CF flag contains the last bit shifted out of the destination operand.
The shift arithmetic left (SAL) and shift logical left (SHL)
Instructions perform the same operation; they shift the bits in the destination operand to the left (toward more significant bit locations). For each shift count, the most significant bit of the destination operand is shifted into the CF flag, and the least significant bit is cleared.
The shift arithmetic right (SAR) and shift logical right (SHR)
Instructions shift the bits of the destination operand to the right (toward less significant bit locations). For each shift count, the least significant bit of the destination operand is shifted into the CF flag, and the most significant bit is either set or cleared depending on the instruction type. The SHR instruction clears the most significant bit. The SAR instruction sets or clears the most significant bit to correspond to the sign (most significant bit) of the original value in the destination operand. In effect, the SAR instruction fills the empty bit position's shifted value with the sign of the unshifted value.
The SAR and SHR
Instructions can be used to perform signed or unsigned division, respectively, of the destination operand by powers of 2. For example, using the SAR instruction to shift a signed integer 1 bit to the right divides the value by 2.
Using the SAR instruction to perform a division operation does not produce the same result as the IDIV instruction. The quotient from the IDIV instruction is rounded toward zero, whereas the "quotient" of the SAR instruction is rounded toward negative infinity. This difference is apparent

You May Also Find These Documents Helpful

  • Good Essays

    Nt1310 Unit 5 Lab Report

    • 490 Words
    • 2 Pages

    INPUT ADDRESS OUTPUT ADDRESS 0.01 – defected bottle Shift 0.02 – shift and counter Shift 0.03 Shift 10.00 100.01 10.01 100.02 10.02 100.03 10.03 100.04…

    • 490 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    cout << "Select the operator you want to work (+ for addition, - for subtraction , * for multiplication , / for division):- ";…

    • 426 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    SD1230 Lab 1

    • 239 Words
    • 2 Pages

    2. What type of instruction is used to execute different code based on a condition? -Jumps…

    • 239 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    b. 1 represents a bit that is turned ON. 0 represents a bit that is turned OFF. (pg. 8)…

    • 388 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Homework Unit 3

    • 354 Words
    • 2 Pages

    4. AND operator- combines more than one condition in a program. Makes a compunf Boolean operation.…

    • 354 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Unit 59 Assignment 3

    • 645 Words
    • 3 Pages

    The process of how the subroutine works within an operating environment is as follows. While the main part of the program is running, there will be a call command sent to the CPU to tell it to stop wherever the program is at, store the W, Z and status along with where in the main program the CPU is at in the stack. Then the main program is cleared from memory and the subroutine is loaded for the CPU to start processing the code. Once the subroutine has finished, the subroutine code is deleted from memory and the CPU will load up the main program back on and will retrieve from stack the stored information (W, Z and status) which will allow the CPU know exactly where it needs to start from.…

    • 645 Words
    • 3 Pages
    Good Essays
  • Powerful Essays

    ● Converts the value of i to double and stores it in d. This conversion is done automatically by the compiler, because double data type is normally wider than int, there is absolutely no risk storing int in double.…

    • 2338 Words
    • 10 Pages
    Powerful Essays
  • Powerful Essays

    En1320 Unit 1 Research Paper 1

    • 27742 Words
    • 111 Pages

    write back the result to memory. The complete assembly program to compute the value of…

    • 27742 Words
    • 111 Pages
    Powerful Essays
  • Satisfactory Essays

    C. It will move the contents of temp1 from directory temp to temp1 of current directory and when finished it will erase the contents of temp1 of temp directory…

    • 529 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Doc. Unix

    • 1228 Words
    • 5 Pages

    b. It is used to perform division on the results of a numerical command operator.…

    • 1228 Words
    • 5 Pages
    Good Essays
  • Good Essays

    Macro Examples

    • 1120 Words
    • 5 Pages

    7. The If…Then…Else…End If code allows code to be conditionally executed depending on whether a specified logical condition has been met.…

    • 1120 Words
    • 5 Pages
    Good Essays
  • Satisfactory Essays

    Homework

    • 343 Words
    • 2 Pages

    68. In the HCS12, the stack pointer (SP) points to _____________ (the last used, next available) location of the stack.…

    • 343 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Chapter 2: Data Manipulation Computer Science: An Overview Eleventh Edition by J. Glenn Brookshear Copyright © 2012 Pearson Education, Inc. Chapter 2: Data Manipulation • • • • • • 2.1 Computer Architecture 2.2 Machine Language 2.3 Program Execution 2.4 Arithmetic/Logic Instructions 2.5 Communicating with Other Devices 2.6 Other Architectures Copyright © 2012 Pearson Education, Inc. 0-2 1 Computer Architecture • Central Processing Unit (CPU) or processor – Arithmetic/Logic unit versus Control unit – Registers • General purpose • Special purpose • B Bus • Motherboard Copyright © 2012 Pearson Education, Inc. 0-3 Figure 2.1 CPU and main memory connected via a bus…

    • 783 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    Pentium Flaw

    • 521 Words
    • 2 Pages

    Many software packages, including many that do use floating point numbers, don’t actually use a computer’s FPU. These packages don’t show the error. Also, only certain numbers whose binary representation show specific bit patterns divide incorrectly. Consequently many users may never encounter the division error. The most famous example and the worst well-known case is 4195835/3145727, discovered by Tim Coe. Under certain data dependent conditions, low order bits of the result of floating point division operations would be incorrect, an error that can quickly compound in floating point operations to much larger errors in subsequent calculations. Intel corrected the error in a future chip revision, but nonetheless declined to disclose it.…

    • 521 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Library Management System

    • 1906 Words
    • 8 Pages

    The objects involved in the operation are listed from left to right according to when they take part in the message sequence.…

    • 1906 Words
    • 8 Pages
    Powerful Essays