Delphi XE2,简单代码:
function FastSwap(Value: uint16): uint16; register; overload;
asm
bswap eax
shr eax, 16
end;
...
type
PPicEleHdr = ^TPicEleHdr;
TPicEleHdr = packed record
zero, size, count: word;
end;
var
count: integer;
buf: TBytes;
begin
...
peh := @buf[offs];
count := integer(FastSwap(peh.count));
for i := 0 to count - 1 do begin
在这里for
我在 CPU 窗口中看到
UnitExtract.pas.279: for i := 0 to count - 1 do begin
0051E459 8B45DC mov eax,[ebp-$24]
0051E45C 48 dec eax
0051E45D 85C0 test eax,eax
0051E45F 0F82CD000000 jb $0051e532
0051E465 40 inc eax
0051E466 8945AC mov [ebp-$54],eax
0051E469 C745F400000000 mov [ebp-$0c],$00000000
因此,当计数0
没有正常工作时,test eax, eax
(eax = $FFFFFFFF after dec eax
)在通过进位标志执行时不会影响进位jb
标志。使用中有什么我不明白的地方for
吗?