本文介绍了FillChar,但用于整数/基数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

FillChar是用相同值的字节填充内存补丁的最快方法(不是零,因为它有ZeroMemory),但是用相同的序列填充内存是等效的( (四字节)整数或基数值?诸如FillInt或FillLongWord之类的东西?

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在某些Pascal实现中(此处为FreePascal),不知道它是否在Delphi中

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;

...或者某些asm专家可以提供更好的解决方案...

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

您还可以查看FreePascal中的实现。

You could also look at the implementation in FreePascal.

这篇关于FillChar,但用于整数/基数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 09:46