Unusual byte sequence for setting R8 - 128
In a piece of system code (in Delphi) I found this sequence ($ stands for "hex"):
DB $49,$C7,$C0,$80,$00,$00,$00 // MOV R8, 128
Indeed, it sets from R8 to 128 in the debugger. But it won't:
MOV R8D,$80 // or $00000080
do the same thing? Is there something special about the previous byte sequence (speed, setting some flags, etc.) that would make the author of the code prefer it over R8D?
A bit more code upon request:
// 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 procedure called _FillChar
that fills a piece of memory in multiples of one byte (or char), more or less similar to memset()
in other languages.
+3
source to share
No one has answered this question yet
Check out similar questions: