开发者

FillChar, but for integer/cardinal

开发者 https://www.devze.com 2022-12-16 23:39 出处:网络
The word has it FillChar is about the fastest way to fill a patch of memory 开发者_高级运维with bytes of the same value (not zero, for that there\'s ZeroMemory), but is there an equivalent to fill mem

The word has it FillChar is about the fastest way to fill a patch of memory 开发者_高级运维with bytes of the same value (not zero, for that there's ZeroMemory), but is there an equivalent to fill memory with a sequence of the same (four byte) integer or cardinal value? Something like FillInt or FillLongWord?


FillDWord is in some Pascal implementations (FreePascal here), don't know if it's in Delphi.

Maybe some simple assembler implementation?

procedure FillDWord( var Destination; Count: Integer; Value: DWord ); 
assembler; register;
asm
  push edi
    mov  edi, eax  // assign Destination
    mov  eax, ecx  // assign Value
    mov  ecx, edx
    rep  stosd
  pop edi
end;

... or some asm expert could give a better one...

You could also look at the implementation in FreePascal.

0

精彩评论

暂无评论...
验证码 换一张
取 消