Registriert seit: 6. Apr 2011
Ort: Berlin
3.070 Beiträge
Delphi 10.4 Sydney
|
AW: Beste IsHEX( AChar : Char ) Methode um Character auf HEX zu prüfen ?
24. Jul 2020, 13:41
Delphi-Quellcode:
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils;
function IsHEX( const AChar: Char): Boolean;
begin
case AChar of
' 0' .. ' 9', ' A' .. ' F', ' a' .. ' f':
Result := True;
else
Result := False;
end;
end;
begin
try
Writeln(' 0: ', IsHEX(' 0').ToString(TUseBoolStrs.True));
Writeln(' 9: ', IsHEX(' 9').ToString(TUseBoolStrs.True));
Writeln(' a: ', IsHEX(' a').ToString(TUseBoolStrs.True));
Writeln(' f: ', IsHEX(' f').ToString(TUseBoolStrs.True));
Writeln(' A: ', IsHEX(' A').ToString(TUseBoolStrs.True));
Writeln(' F: ', IsHEX(' F').ToString(TUseBoolStrs.True));
Writeln(' -: ', IsHEX(' -').ToString(TUseBoolStrs.True));
Writeln(' /: ', IsHEX(' /').ToString(TUseBoolStrs.True));
Writeln(' g: ', IsHEX(' g').ToString(TUseBoolStrs.True));
Writeln(' z: ', IsHEX(' z').ToString(TUseBoolStrs.True));
Writeln(' G: ', IsHEX(' G').ToString(TUseBoolStrs.True));
Writeln(' Z: ', IsHEX(' Z').ToString(TUseBoolStrs.True));
except
on E: Exception do
Writeln(E.ClassName, ' : ', E. Message);
end;
Readln;
end.
Produziert ( Win32 Debug):
Code:
Project1.dpr.11: begin
0041B050 55 push ebp
0041B051 8BEC mov ebp,esp
0041B053 51 push ecx
0041B054 668945FE mov [ebp-$02],ax
Project1.dpr.12: case AChar of
0041B058 668B45FE mov ax,[ebp-$02]
0041B05C 83C0D0 add eax,-$30
0041B05F 6683E80A sub ax,$0a
0041B063 7212 jb +18 ; $0041b077
0041B065 83C0F9 add eax,-$07
0041B068 6683E806 sub ax,$06
0041B06C 7209 jb +9 ; $0041b077
0041B06E 83C0E6 add eax,-$1a
0041B071 6683E806 sub ax,$06
0041B075 7306 jnb +6 ; $0041b07d
Project1.dpr.14: Result := True;
0041B077 C645FD01 mov byte ptr [ebp-$03],$01
0041B07B EB04 jmp +4 ; $0041b081
Project1.dpr.16: Result := False;
0041B07D C645FD00 mov byte ptr [ebp-$03],$00
Project1.dpr.18: end;
0041B081 8A45FD mov al,[ebp-$03]
0041B084 59 pop ecx
0041B085 5D pop ebp
0041B086 C3 ret
|
|
Zitat
|