Shift and loop commands

Source: Internet
Author: User

The logic shifts one digit to the left, which is equivalent to the unsigned number multiplied by 2.
The logic shifts one digit to the right, which is equivalent to the number of unsigned characters divided by 2.
1) arithmetic shift when the multiplier or divisor is 2n, the arithmetic shift is used to quickly perform multiplication or Division operations on integers. Shift n places to the left is equivalent to multiply by 2n. The execution method is to move each bit of the original number to N places on the left, and discard n places on the left, fill 0 in all the positions of the Low-position void on the right.
2) The logic shift logic shifts n places to the left. This is to move each bit of the original number to N places on the left. Do not discard the high positions on the left, fill "0" in the left position of the low position ". The logical right shift N-bit execution method is to move each digit in the original number N-places to the right, do not discard the low position removed from the right, all fill 0 in the left high empty position.

Differences between arithmetic shift and logical shift:
There is no difference between the logical left shift and the arithmetic left shift. There is no difference between the two writing methods (equivalent to the unsigned number multiplication 2) The right shift has no difference between the arithmetic right shift highest bit (equivalent to the signed number Division 2) logic shifted to the right highest bit no matter what is filled with 0 (equivalent to no symbol number Division 2)
The so-called right shift of a loop is to shift the last digit to the first digit.
Its function: for example, if you want a group of small lights to be on one by one, you can shift right (for example, the number of 1000000) and output it, so that it will be on one by one.
A bitwise loop is a C loop that is carried to the Left or Right Loop.
Because the operation of some commands affects the flag bit (such as C), then adding a C loop can implement some special functions.
It depends on what you want to do.
The effect of the shift instruction on the condition codes in the sign register:
Of: valid when the number of moves is 1. After the shift, the highest valid bit is changed. The of position is 1; otherwise, it is 0.
Cf: Based on the command execution result
PF, SF, and ZF are set based on execution results.
AF: no specific definition.

Note: If the number of shifted digits is greater than 1, the CL register must be used to indicate the number of shifted digits.
5) Cyclic left shift command
6) Bring-in loop left shift command
RCL opr, count
7) Cyclic right shift command
8) the cyclic right shift command of the incoming bits
RCR opr, count

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.