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,194 of 4,675   
   Bartc to James Van Buskirk   
   Re: asm improvements?   
   21 Dec 17 18:29:28   
   
   From: bc@nospicedham.freeuk.com   
      
   On 21/12/2017 06:14, James Van Buskirk wrote:   
   > "Bartc"  wrote in message news:fxdZB.23554$4O3.2385@fx15.am4...   
   >   
   >> On 16/12/2017 17:40, James Van Buskirk wrote:   
   >   
   >> > The above numbering doesn't reflect the   
   >> > overlap between RBP and R13 or RSP and R12.   
   >   
   >> What overlap is that: that the bottom 3 bits of the register code? And   
   >> why is it important, as all bottom 8 registers will 'overlap' with the   
   >> top 8?   
   >   
   > I refer you to 325462.pdf, Vol. 2A p. 2-11, table 2-5.  An SIB byte is   
   > required for R12-based addressing and R13 can't be used without   
   > displacement, although the displacement can be zero.   
      
   I can't see how this is relevant. It's all to do with internal encoding   
   of the instruction set. It doesn't really affect how it's programmed.   
      
   If I write this code:   
      
   	mov ax,word [RAX]   
   	mov ax,word [RCX]   
   	mov ax,word [RDX]   
   	mov ax,word [RBX]   
   	mov ax,word [RSP]   
   	mov ax,word [RBP]   
   	mov ax,word [RSI]   
   	mov ax,word [RDI]   
      
   	mov ax,word [R8]   
   	mov ax,word [R9]   
   	mov ax,word [R10]   
   	mov ax,word [R11]   
   	mov ax,word [R12]   
   	mov ax,word [R13]   
   	mov ax,word [R14]   
   	mov ax,word [R15]   
      
   It is encoded as follows:   
      
      
   66 8B 00 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rax]   
   66 8B 01 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rcx]   
   66 8B 02 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rdx]   
   66 8B 03 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rbx]   
   66 8B 04 24 -- -- -- -- -- -- -- -- -- -- mov ax,  word [rsp]   
   66 8B 45 00 -- -- -- -- -- -- -- -- -- -- mov ax,  word [rbp]   
   66 8B 06 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rsi]   
   66 8B 07 -- -- -- -- -- -- -- -- -- -- -- mov ax,  word [rdi]   
   66 41 8B 00 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r8]   
   66 41 8B 01 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r9]   
   66 41 8B 02 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r10]   
   66 41 8B 03 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r11]   
   66 41 8B 04 24 -- -- -- -- -- -- -- -- -- mov ax,  word [r12]   
   66 41 8B 45 00 -- -- -- -- -- -- -- -- -- mov ax,  word [r13]   
   66 41 8B 06 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r14]   
   66 41 8B 07 -- -- -- -- -- -- -- -- -- -- mov ax,  word [r15]   
      
   You can see the extra bytes needed to overcome the restrictions with   
   RSP/RBP and the matching R12/13, but, so what?   
      
   If I write using my register names:   
      
   	mov ax,word [D0]   
   	mov ax,word [D1]   
   	mov ax,word [D2]   
   	mov ax,word [D3]   
   	mov ax,word [D4]   
   	mov ax,word [D5]   
   	mov ax,word [D6]   
   	mov ax,word [D7]   
   	mov ax,word [D8]   
   	mov ax,word [D9]   
   	mov ax,word [D10]   
   	mov ax,word [D11]   
   	mov ax,word [D12]   
   	mov ax,word [D13]   
   	mov ax,word [D14]   
   	mov ax,word [D15]   
      
   Then encoding (also using the new names) is:   
      
   66 8B 00 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D0]   
   66 8B 03 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D1]   
   66 8B 06 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D2]   
   66 8B 07 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D3]   
   66 41 8B 02 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D4]   
   66 41 8B 03 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D5]   
   66 41 8B 04 24 -- -- -- -- -- -- -- -- -- mov W0,  word [D6]   
   66 41 8B 45 00 -- -- -- -- -- -- -- -- -- mov W0,  word [D7]   
   66 41 8B 06 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D8]   
   66 41 8B 07 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D9]   
   66 8B 01 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D10]   
   66 8B 02 -- -- -- -- -- -- -- -- -- -- -- mov W0,  word [D11]   
   66 41 8B 00 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D12]   
   66 41 8B 01 -- -- -- -- -- -- -- -- -- -- mov W0,  word [D13]   
   66 8B 45 00 -- -- -- -- -- -- -- -- -- -- mov W0,  word [Dframe]   
   66 8B 04 24 -- -- -- -- -- -- -- -- -- -- mov W0,  word [Dstack]   
      
   The address modes needing extra bytes have just moved around a little.   
      
   >   
   > Whatever numbering you choose for the registers, different ABIs   
   > will use them for different purposes, so ordering them to match   
   > one ABI doesn't make all that much sense to me.   
      
   Most of the time I'm using my own ABI, so it doesn't matter. But when   
   need to use an official ABI, and this will usually be Win64, so that is   
   what it's designed for. It makes life easier it you do a lot of coding   
   for that.   
      
   I can't see that using the same register names will make it any easier   
   to use different ABIs with different parameter passing registgers.   
      
   --   
   bartc   
      
   --- 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