DWORD Bytes "füllen"



  • Hallo,

    klingt komisch, ist aber ganz einfach. Ich möchte jedes Byte eines DWORDs mit dem gleichen Byte-Wert füllen.

    Ich möchte mein DWORD also so füllen
    Byte 1 = 1
    Byte 2 = 1
    Byte 3 = 1
    Byte 4 = 1

    Ich denke es solle jetzt klar sein 😉

    Auf welche Art tut man dass am besten?

    Momentan mache ich es so, bin mir aber nicht sicher, ob es da nicht noch eine bessere Möglichkeit gibt - funktionieren tut`s natürlich auc so:

    void __fastcall FillDWORD( unsigned int* DW, const unsigned char& Byte )
    {
    	__asm 
    	{
    [asm]		push ebx
    
    		xor ebx, ebx
    		mov dl, byte ptr [edx]
    
    		xor eax, eax
    		mov al, dl
    		shl eax, 24
    		add ebx, eax
    
    		xor eax, eax
    		mov al, dl
    		shl eax, 16
    		add ebx, eax
    
    		mov bl, dl
    		mov bh, dl
    
    		mov dword ptr [ecx], ebx
    
    		pop ebx[/asm]
    	}
    }
    


  • Vielleicht so hier:

    mov dl, byte ptr [edx]
    
     mov al,dl
     mov ah,dl
     shl eax,16
     mov al,dl
     mov ah,dl
    
     mov dword ptr [ecx], eax
    

    Oder so: 🙂

    mov   al,byte ptr [edx]
    
     movzx eax,al
     mov   edx,001010101h
     imul  edx
    
     mov   dword ptr [ecx], eax
    

Anmelden zum Antworten