home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.asm.x86      Ahh, the lost art of x86 assembly      4,675 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 3,969 of 4,675   
   Mike Gonta to All   
   Re: using shrd instruction in 16-bit cod   
   19 Nov 19 03:18:17   
   
   From: mikegonta@nospicedham.gmail.com   
      
   On Tuesday, November 19, 2019 at 3:35:46 AM UTC-5, bilsch01 wrote:   
   > If I understand correctly for: shrd ax,dx,cl   
   > ax gets shifted right, dx provides bits to shift into ax from left.   
   > For a 32-bit number 3ffff in dx:ax   
   > (in binary that's eighteen 1's in a row)   
   > I try the following:   
   >   
   > mov cl,2   
   > mov dx,3   
   > mov ax,0xffff   
   > shrd ax,dx,cl   
   > cmp dx,0   
   > jne error   
   >   
   > I thought dx would be shifted empty but it's not.   
      
   That's right - it's not.   
   The source register (in this case dx) only provides the bits to be shifted   
   into the destination (ax). To obtain the complete 32 bit shift the source also   
   needs to be shifted.   
   [code]   
     shrd ax, dx, cl   
     shr dx, cl   
   [/code]   
      
   _________________   
   Mike Gonta   
   the-ideom - now you know how to compile   
      
   https://mikegonta.com   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca