Нашли или выдавили из себя код, который нельзя назвать нормальным,
на который без улыбки не взглянешь?
Не торопитесь его удалять или рефакторить, — запостите его на
говнокод.ру, посмеёмся вместе!
Авторы - программисты из FTDI, взято из экзамплов работы с USB-конвертерами.
Полный текст можно найти здесь: __http://www.ftdichip.com/Support/SoftwareExamples/CodeExamples/Delphi.htm
З.Ы. Ниже по тексту идет аналогичная функция HexByteToStr. Алгоритм, так сказать, тот же.
Str := SetupForm.BaudSelect.Text;
If Str = '300' then FT_Current_Baud := FT_BAUD_300 else
If Str = '600' then FT_Current_Baud := FT_BAUD_600 else
If Str = '1,200' then FT_Current_Baud := FT_BAUD_1200 else
If Str = '2,400' then FT_Current_Baud := FT_BAUD_2400 else
If Str = '4,800' then FT_Current_Baud := FT_BAUD_4800 else
If Str = '9,600' then FT_Current_Baud := FT_BAUD_9600 else
If Str = '19,200' then FT_Current_Baud := FT_BAUD_19200 else
If Str = '38,400' then FT_Current_Baud := FT_BAUD_38400 else
If Str = '57,600' then FT_Current_Baud := FT_BAUD_57600 else
If Str = '115,200' then FT_Current_Baud := FT_BAUD_115200 else
If Str = '230,400' then FT_Current_Baud := FT_BAUD_230400 else
If Str = '460,800' then FT_Current_Baud := FT_BAUD_460800 else
If Str = '921,600' then FT_Current_Baud := FT_BAUD_921600 else
FT_SetupError := True;
If Str = '300' then FT_Current_Baud := FT_BAUD_300 else
If Str = '600' then FT_Current_Baud := FT_BAUD_600 else
If Str = '1,200' then FT_Current_Baud := FT_BAUD_1200 else
If Str = '2,400' then FT_Current_Baud := FT_BAUD_2400 else
If Str = '4,800' then FT_Current_Baud := FT_BAUD_4800 else
If Str = '9,600' then FT_Current_Baud := FT_BAUD_9600 else
If Str = '19,200' then FT_Current_Baud := FT_BAUD_19200 else
If Str = '38,400' then FT_Current_Baud := FT_BAUD_38400 else
If Str = '57,600' then FT_Current_Baud := FT_BAUD_57600 else
If Str = '115,200' then FT_Current_Baud := FT_BAUD_115200 else
If Str = '230,400' then FT_Current_Baud := FT_BAUD_230400 else
If Str = '460,800' then FT_Current_Baud := FT_BAUD_460800 else
If Str = '921,600' then FT_Current_Baud := FT_BAUD_921600 else
FT_SetupError := True;
D2XXUnit оттуда же
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 ESI
end;
Здесь же все непонятно. А у них - наоборот, все понятно и прозрачно, сразу видно, откуда и как получается каждая цифра.