TITLE INCLUDE Irvine32.inc COUNT = 4 ; shift count .data array DWORD 11111111h,22222222h,33333333h,44444444h,55555555h .code main PROC mov bl,COUNT call ShiftDoublewords ; Display the results mov esi,OFFSET array mov ecx,LENGTHOF array mov ebx,TYPE array call DumpMem exit main ENDP ShiftDoublewords PROC ; ; Shifts an array of doublewords to the right. ; The array is a global variable. ; Receives: BL = number of bits to shift ; Returns: nothing ;--------------------------------------------------------------- mov esi,OFFSET array mov ecx,(LENGTHOF array) - 1 L1: push ecx ; save loop counter mov eax,[esi + TYPE DWORD] mov cl,bl ; shift count shrd [esi],eax,cl ; shift EAX into high bits of [esi] add esi,TYPE DWORD ; point to next doubleword pair pop ecx ; restore loop counter loop L1 ; Right-shift the last doubleword mov cl,bl ; shift count mov edi,OFFSET array mov eax,[edi] shrd [esi],eax,cl ; shift EAX into high bits of [esi] ret ShiftDoublewords ENDP END main