Unusual byte sequence to set R8 to 128

Viewed 129

In a piece of system code (in Delphi), I found this sequence ($ means "hex"):

    DB      $49,$C7,$C0,$80,$00,$00,$00  // MOV  R8, 128

And indeed, it sets R8 to 128 in the debugger. But wouldn't:

    MOV     R8D,$80 // or $00000080

do the same? Is there something special about the former byte sequence (speed, setting some flags, whatever) that could have made the author of the code prefer it over the way using R8D?


On request, a little more of the code:

// RAX/XMM : 16BYTES VALUE. RDX: COUNT. RCX: DEST. ADDRESS. (16BTYES ALIGNED)
@@COPY128:
        DB    $49,$C7,$C0,$80,$00,$00,$00  // MOV  R8, 128
        CMP   RDX,R8
        JL    @@COPY64
        SUB   RDX,R8
        DB    $0F,$1F,$80,$00,$00,$00,$00 // NOP DWORD PTR [EAX + 00000000H] ; NOP(7)
@@COPY128LOOP:
        MOVDQA [RCX      ],XMM0
        MOVDQA [RCX + $10],XMM0
        MOVDQA [RCX + $20],XMM0
        MOVDQA [RCX + $30],XMM0
        MOVDQA [RCX + $40],XMM0
        MOVDQA [RCX + $50],XMM0
        MOVDQA [RCX + $60],XMM0
        MOVDQA [RCX + $70],XMM0
        ADD   RCX,R8
        SUB   RDX,R8
        JG    @@COPY128LOOP
        ADD   RDX,R8

@@COPY64:

This is part of a routine called _FillChar, which fills a piece of memory with multiples of a single byte (or char), more or less like memset() in other languages.

0 Answers
Related