SysUtils.pas单元函数IntToHex函数学习笔记
1.函数原型:
function IntToHex(Value: Integer; Digits: Integer): string;// FmtStr(Result, '%.*x', [Digits, Value]);asm CMP EDX, 32 // Digits < buffer length? JBE @A1 XOR EDX, EDX@A1: PUSH ESI MOV ESI, ESP SUB ESP, 32 PUSH ECX // result ptr MOV ECX, 16 // base 16 EDX = Digits = field width CALL CvtInt MOV EDX, ESI POP EAX // result ptr CALL System.@LStrFromPCharLen ADD ESP, 32 POP ESIend;function IntToHex(Value: Int64; Digits: Integer): string;// FmtStr(Result, '%.*x', [Digits, Value]);asm CMP EAX, 32 // Digits < buffer length? JLE @A1 XOR EAX, EAX@A1: PUSH ESI MOV ESI, ESP SUB ESP, 32 // 32 chars MOV ECX, 16 // base 16 PUSH EDX // result ptr MOV EDX, EAX // zero filled field width: 0 for no leading zeros LEA EAX, Value; CALL CvtInt64 MOV EDX, ESI POP EAX // result ptr CALL System.@LStrFromPCharLen ADD ESP, 32 POP ESIend;//有时间研究下汇编指令。(*^__^*) 嘻嘻……大家谁有时间研究好了可以回帖给我哦