Win32 compilation [24]-shift: SHL, SHR, Sal, SAR, Rol, Ror, RCL, RCR, shld, shrd

Source: Internet
Author: User
SHL, SHR, Sal, and SAR: Shift instruction
; SHL (shift left): Logical left shift; SHR (shift right): Logical right shift; Sal (shift arithmetic left): arithmetic left shift; SAR (shift arithmetic right): arithmetic right shift; SHL and Sal are the same, but SHR and SAR are different .; SHL, SAL: Left shift for each person, low fill 0, High Fill CF; SHR: right shift for each person, low fill CF, High Fill 0; SAR: right shift for each person, low move into CF, high remain unchanged; their results affect the command formats of, SF, ZF, PF, and CF, which are shl r/m, i8shl R/m, and Cl.

  ; Test24_1.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codemain proc; SHL, Al mov Al, 11100111b SHL Al, 1 printhex al; Ce-11001110b Sal Al, 2 printhex al; 38-00111000b mov Al, 11100111b mov Cl, 2 SHL Al, CL printhex al; 9C-10011100b; SHR mov Al, 11100111b SHR Al, 2 printhex al; 39-00111001b; SAR mov Al, 11100111b SAR Al, 2 printhex al; f9-11111001b retmain endpend main

  

ROL, Ror, RCL, RCR: cyclic shift instruction

; ROL (rotate left): Cycle left shift; ror (rotate right): cycle right shift; RCL (rotate through carry left): Bring-in loop left shift; RCR (rotate through carry right ): shift to the right of the bitwise loop; ROL: shift to the left of the loop, send CF to the lower position, and send CF to the lower position; ror: shift to the right of the loop, send CF to the lower position, RCL: shift left of the loop, carry value (original CF) up to the low position, high to CF; RCR: Right Shift of the loop, carry value (original CF) to the high position, low to CF; their results affect of and CF; their command formats are the same: shl r/m, i8shl R/m, Cl
  
   
 ; Test24_2.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codemain proc; ROL mov Al, 111_11b ROL Al, 1 printhex al; 87-01_111b; ror mov Al, 111_11b ror Al, 1 printhex al; E1-111_1b; rcl clc mov Al, 10101111b RCL Al, 1 printhex al; 5E-01011110b STC mov Al, 10101111b RCL Al, 1 printhex al; 5f-01011111b CLC mov Al, 10101111b RCL Al, 2 printhal; BD-10111101b; rcr clc mov Al, 11101011b RCR Al, 2 printhex al; BA-10111010b retmain endpend main
  
   
 

Shld and shrd: Double Precision shift

; Shld (double-precision shift left): shifts left with double precision; shrd (double-precision shift right): Shifts right with double precision; shld and shrd have three operands; operand 3: Shift number; operand 1: It is the destination operand. The removed bits on the left of shld are filled with the highest bits of the same number in the operand two. The removed bits on the Right of shrd are filled with the low bits of the same number in the operand two; the two operands remain unchanged and must be registers. Their results affect the shld, SF, ZF, PF, and CF commands in the same format: shld R16/32/M16/M32, r16/32, i8shld R16/32/M16/M32, R16/32, Cl

  ; Test25_3.asm.386.model flat, stdcallinclude windows. incinclude kernel32.incinclude masm32.incinclude debug. incincludelib kernel32.libincludelib masm32.libincludelib debug. lib. codemain proc; shld mov ax, 1_mov dx, 111111111_ B shld ax, dx, 2 printhex ax; 33c3-001100111_11b; shrd mov ax, 1_mov dx, 1_111111b shrd ax, dx, 2 printhex ax; c3cc-111_1111001100b retmain endpend main

  

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: info-contact@alibabacloud.com 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.