.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.code
main PROC;如果有符号数循环移动一位生成的结果超过了目的操作数的有符号范围;溢出就为1,换句话说:即该数的符号位取反了mov al,+127;AL =01111111brol al,1;OF =1,AL =11111110bmov al,-128;10000000Bshr al,1;OF =1,AL =01000000b;如果循环移动次数大于1,则溢出标志无定义mov al,-128;10000000Bshr al,1;OF =0,AL =00100000bINVOKE ExitProcess,0
main ENDP
END main
3:双精度移位SHLD,SHRD
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.data
wval WORD 9BA6h.code
main PROC;双精度左移,将AX的高4位复制到wval的低4位mov ax,0AC36hshld wval,ax,4;wval = BA6Ah ,ax = AX36h;双精度右移,将dx的低4位复制到ax的高4位mov ax,234Bhmov dx,7654hshrd ax,dx,4;ax =4234INVOKE ExitProcess,0
main ENDP
END main
4 : 双精度移位例子,将一个双字数组右移4位
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.data
array DWORD 648B2165h,8C943A29h,6DFA4B86h,91F76C04h,8BAF9857h.code
main PROCmov bl,4;移动次数mov esi,OFFSET array ;数组偏移量mov ecx,(LENGTHOF array)-1;数组元素个数
L1:push ecxmov eax,[esi + TYPE DWORD]mov cl,bl ;移动次数shrd [esi],eax,cl ;EAX移入[ESI]的高位add esi,TYPE DWORD ;指向下一对双字pop ecxloop L1shr DWORD PTR[esi],4;最后一个双字进行移位INVOKE ExitProcess,0
main ENDP
END main
5 :不用使用SHRD指令将AX的最低移入BX的最高位,再使用SHRD指令移入
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.code
main PROC;不使用SHRD指令,将AX的最低位移入BX的最高位mov ax,1111111111111111bmov bx,0011111111111111bmov si,axshr si,1rcr bx,1;使用SHRD指令,将AX的最低位移入BX的最高位mov ax,1111111111111111bmov bx,0011111111111111bshrd bx,ax,1INVOKE ExitProcess,0
main ENDP
END main
6:利用循环将EAX的每一位移入进位标志位,计算进位标志位置的1次数,计算32位数奇偶性
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.code
main PROCmov ebx,0mov ecx,32mov eax,89ABCDEFh
L1:ror eax,1jnc L2inc ebx
L2:loop L1and ebx,1jz L3mov edx,0;奇数jmp quit
L3:mov edx,1;偶数quit:INVOKE ExitProcess,0
main ENDP
END main
7:使用shr与rcr 将 字节数组右移一位
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.data
ArraySize =3
array BYTE ArraySize DUP(99h);每半个字节都是1001.code
main PROCmov esi,0shr array[esi+2],1;高字节rcr array[esi+1],1;中间字节,包括进位标志位rcr array[esi],1;低字节,包含进位标志位INVOKE ExitProcess,0
main ENDP
END main
8:将无符号整数乘法,转换成使用SHL和ADD计算
.386.model flat,stdcall.stack 4096
ExitProcess PROTO,dwExitCode:DWORD.code
main PROC;123*36 可以使用以下位运算替换;36=00100100;乘数36的位2和位5都是1,所以下面123左移5位和2位相加mov eax,123mov ebx,eaxshl eax,5;shl ebx,2add eax,ebx ;乘积相加INVOKE ExitProcess,0
main ENDP
END main
Random numbers just numbers that lie within a range and any of the numbers can occur. 随机数只是在一个范围内的数字,任何数字都可能出现。 In programming, we come through a lot of scenarios where we need to generate random numbers. Like for dice g…
python调用带参函数There are following types of function calls in python: python中有以下类型的函数调用: Call by value 按价值致电 Call by reference 通过参考电话 1)按价值致电 (1) Call by value ) When, we call a function with the values i.e. pass …
这是一个弹出层的插件,有时候做东西的,经常会用到了,所以在次发一下,和大家分享一下! [task]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/x…
MathContext类的hashCode()方法 (MathContext Class hashCode() method) hashCode() method is available in java.math package. hashCode()方法在java.math包中可用。 hashCode() method is used to get the hash code value of this MathContext. hashCode()方法用于获取此M…
LocalDate类minusYears()方法 (LocalDate Class minusYears() method) minusYears() method is available in java.time package. minusYears()方法在java.time包中可用。 minusYears() method is used to subtract the given years from this LocalDate and return the LocalD…