Software Solution for Engineers and Scientist Episode 2

Tham khảo tài liệu 'software solution for engineers and scientist episode 2', kỹ thuật - công nghệ, cơ khí - chế tạo máy phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 64 Chapter 3 eration described above. In this opcode the right-most bit is moved into the carry flag. Figure shows the action of the 80x86 shift instructions. The 80x86 opcodes for performing a bit shift to the left are SHL shift logical left and SAL shift arithmetic left . Notice that SHL and SAL are different mnemonics for the same operation see Figure . In SHL and SAL it is the left-most bit of the operand that is moved into the carry flag. The terms logical and arithmetic as used in the SHL and SAL opcodes reflect a potential problem associated with shifting bits in a signed representation. The problem is that negative numbers in two s complement form always have the high bit set. Therefore when the bits of a two s complement number are shifted the sign bit can change unpredictably. For this reason in left-shift operations of signed operands the sign bit is moved into the carry flag. After performing the shift software can test the carry flag and make the necessary adjustments. On the other hand in a right-shift operation the sign bit is moved from bit number 7 to bit number 6 and a zero bit is introduced into the sign bit position. This action makes all signed numbers positive. In order to make possible shift operations of signed numbers the 80x86 instruction set has a separate opcode for the right-shift of signed numbers. The SAR opcode shift arithmetic right preserves the sign bit bit number 7 while shifting all other bits to the right. This action can be seen in the diagram for the SAR instruction in Figure . Note that in the SAR instruction the left-most bit sign bit is both preserved and shifted. For example the value 10000000B becomes 11000000B after executing the SAR operation. This action is sometimes called a sign extension operation. SHL - shift logical left SAL - shift arithmetic left 7 6 5 4 3 2 1 0 CF 0 76543210 SHR - shift logical right 76543210 CF SAR - shift arithmetic right 76543210 Figure 80x86 Bit Shift Instructions Machine .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
1357    3    1    12-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.