TAlpha::FillSolidColor 部分汇编

for (i = Width - 1; i >= 0; i--)                                   
 {                                                                 
  *((unsigned short int *)ptrDest) = *((unsigned short int *)brgb);
  ptrDest++;                                                       
  ptrDest++;                                                       
  *ptrDest++ = brgb[2];                                            
 }                                                                 

 

:004243E2 8B75FC  mov esi, dword ptr [ebp-04] ; esi = i            
:004243E5 4E      dec esi   
:004243E6 85F6    test esi, esi
:004243E8 7C38    jl 00424422   
:004243EA 668B02  mov ax, word ptr [edx]      ; edx = brgb
:004243ED 4E      dec esi    
:004243EE 668903  mov word ptr [ebx], ax      ; ebx = ptrDest            
:004243F1 43      inc ebx                
:004243F2 43      inc ebx
:004243F3 8A4A02  mov cl, byte ptr [edx+02]
:004243F6 880B    mov byte ptr [ebx], cl
:004243F8 43      inc ebx
:004243F9 85F6    test esi, esi
:004243FB 7DED    jge 004243EA

  

for (i = Width - 1; i >= 0; i--)
 {                               
  *ptrDest = brgb[0];            
  ptrDest++;                     
  *ptrDest = brgb[1];            
  ptrDest++;                     
  *ptrDest = brgb[2];            
  ptrDest++;                     
 }                               

 

:00424424 8B75FC  mov esi, dword ptr [ebp-04] ; esi = i
:00424427 4E      dec esi 
:00424428 85F6    test esi, esi    
:0042442A 7C16    jl 00424442     
:0042442C 8A02    mov al, byte ptr [edx]      ; edx = brgb
:0042442E 4E      dec esi     
:0042442F 8803    mov byte ptr [ebx], al      ; ebx = ptrDest
:00424431 43      inc ebx   
:00424432 8A4A01  mov cl, byte ptr [edx+01]  
:00424435 880B    mov byte ptr [ebx], cl
:00424437 43      inc ebx
:00424438 8A4202  mov al, byte ptr [edx+02]
:0042443B 8803    mov byte ptr [ebx], al
:0042443D 43      inc ebx
:0042443E 85F6    test esi, esi
:00424440 7DEA    jge 0042442C

    

   i = Width - 1;
   do
    {
     *((unsigned short int *)ptrDest) = *((unsigned short int *)brgb);
     ptrDest++;
     ptrDest++;
     *ptrDest++ = brgb[2];
     i--;
    }while(i >= 0);

:00424388 8B75F8  mov esi, dword ptr [ebp-08]  ; [ebp-08] = Width
:0042438B 4E      dec esi                      ; i = Width - 1;
:0042438C 8D55F5  lea edx, dword ptr [ebp-0B]  
:0042438F 4E      dec esi                      ; i--
:00424390 668B12  mov dx, word ptr [edx]  
:00424393 668913  mov word ptr [ebx], dx    ; *((unsigned short int *)ptrDest) = *((unsigned short int *)brgb)
:00424396 43      inc ebx                   ; ptrDest++
:00424397 43      inc ebx                   ; ptrDest++
:00424398 8A55F7  mov dl, byte ptr [ebp-09]
:0042439B 8813    mov byte ptr [ebx], dl    ; *ptrDest++ = brgb[2]
:0042439D 43      inc ebx
:0042439E 85F6    test esi, esi
:004243A0 7DEA    jge 0042438C

   register const int pd = iPixelAdd + 2;
   i = Width - 1;
   do
    {
     *ptrDest++ = brgb[0];
     *((unsigned short int *)ptrDest) = *((unsigned short int *)&brgb[1]);

     ptrDest += pd;
     i--;
    }while(i >= 0);

:004243A4 8D7802  lea edi, dword ptr [eax+02]  ; edi = pd
:004243A7 8B75F8  mov esi, dword ptr [ebp-08]
:004243AA 4E      dec esi                      ; i = Width - 1   
:004243AB 8A55F5  mov dl, byte ptr [ebp-0B]
:004243AE 4E      dec esi                      ; i--
:004243AF 8813    mov byte ptr [ebx], dl       ; *ptrDest++ = brgb[0]
:004243B1 8D55F6  lea edx, dword ptr [ebp-0A]  
:004243B4 43      inc ebx
:004243B5 668B12  mov dx, word ptr [edx]
:004243B8 668913  mov word ptr [ebx], dx       ; *((unsigned short int *)ptrDest) = *((unsigned short int *)&brgb[1])
:004243BB 03DF    add ebx, edi                 ; ptrDest += pd
:004243BD 85F6    test esi, esi
:004243BF 7DEA    jge 004243AB


常数完全可以放在寄存器里嘛,非要来回多次读取。

   const unsigned short int igb = ((byte)(Color>>16)) | (((byte)(((WORD)Color)>>8))<<8);
   const byte br = (byte)Color;

   i = Width - 1;
   do
    {
     *((unsigned short int *)ptrDest) = igb;
     ptrDest++;
     ptrDest++;
     *ptrDest++ = br;
     i--;
    }while(i >= 0);

 

:0042439B 4E      dec esi
:0042439C 66893B  mov word ptr [ebx], di  ; *((unsigned short int *)ptrDest) = igb
:0042439F 43      inc ebx  ; ptrDest++
:004243A0 43      inc ebx  ; ptrDest++
:004243A1 4E      dec esi  ; i--
:004243A2 8803    mov byte ptr [ebx], al  ; *ptrDest++ = br
:004243A4 43      inc ebx
:004243A5 85F6    test esi, esi
:004243A7 7DF3    jge 0042439C

这基本是最佳汇编了。
 

   const byte bb = (byte)(Color>>16);
   const unsigned short int irg = ((byte)(((WORD)Color)>>8)) | ((byte)Color<<8);
   register const int pd = iPixelAdd + 2;

   i = Width - 1;
   do
    {
     *ptrDest++ = bb;
     *((unsigned short int *)ptrDest) = irg;

     ptrDest += pd;
     i--;
    }while(i >= 0);


:004243D3 8B75F8  mov esi, dword ptr [ebp-08]
:004243D6 4E      dec esi  
:004243D7 8A4DF3  mov cl, byte ptr [ebp-0D]  ; byte ptr [ebp-0D] = bb
:004243DA 4E      dec esi  ; i--
:004243DB 880B    mov byte ptr [ebx], cl
:004243DD 43      inc ebx
:004243DE 668903  mov word ptr [ebx], ax
:004243E1 03DF    add ebx, edi  ; ptrDest += pd
:004243E3 85F6    test esi, esi
:004243E5 7DF0    jge 004243D7


你可能感兴趣的:(TAlpha::FillSolidColor 部分汇编)