線上訂房服務-台灣趴趴狗聯合訂房中心
發文 回覆 瀏覽次數:3138
推到 Plurk!
推到 Facebook!

請問各位先知........一個.hex檔的轉碼方式

尚未結案
kevinhue
一般會員


發表:23
回覆:42
積分:13
註冊:2003-05-06

發送簡訊給我
#1 引用回覆 回覆 發表時間:2003-05-23 15:38:39 IP:218.160.xxx.xxx 未訂閱
請問一下,電腦程式裡的.hex檔編碼方式是怎麼編的ㄚ??? 因為我想要寫一個hex檔轉bin檔.......                              kevinhue
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#2 引用回覆 回覆 發表時間:2003-05-23 15:54:13 IP:140.135.xxx.xxx 未訂閱
kevinhue您好:   
引言:我想要寫一個hex檔轉bin檔
Help中有個Function FBinFromHex() 不曉得是不是這個 順心 <>~我也是在學習的階段,所以請您多多見諒與指教~
frederick
中階會員


發表:101
回覆:108
積分:66
註冊:2002-08-01

發送簡訊給我
#3 引用回覆 回覆 發表時間:2003-05-24 13:32:14 IP:210.244.xxx.xxx 未訂閱
引言: 請問一下,電腦程式裡的.hex檔編碼方式是怎麼編的ㄚ??? 因為我想要寫一個hex檔轉bin檔....... kevinhue < face="Verdana, Arial, Helvetica"> 您好: 嗯~相關資料網上一大堆,善用搜尋引擎吧~ 在此提供轉貼一例: An Intel Standard HEX file is an ASCII file with one "record" per line. Each line has the following format: Position Description 1 Record Marker: The first character of the line is always a colon (ASCII 0x3A) to identify the line as an Intel HEX file 2 - 3 Record Length: This field contains the number of data bytes in the register represented as a 2-digit hexidecimal number. This is the total number of data bytes, not including the checksum byte nor the first 9 characters of the line. 4 - 7 Address: This field contains the address where the data should be loaded into the chip. This is a value from 0 to 65,535 represented as a 4-digit hexidecimal value. 8 - 9 Record Type: This field indicates the type of record for this line. The possible values are: 00=Register contains normal data. 01=End of File. 02=Extended address. 10 - n Data Bytes: The following bytes are the actual data that will be burned into the EPROM. The data is represented as 2-digit hexidecimal values. Last 2 Checksum: The last two characters of the line are a checksum for the line. The checksum value is calculated by taking the two's complement of the sum of all the preceeding data bytes, excluding the checksum byte itself and the colon at the beginning of the line. Calculating the Checksum As mentioned in the format table above, the last two characters represent a checksum of the data in the line. Since the checksum is a two-digit hexidecimal value, it may represent a value of 0 to 255, inclusive. The checksum is calculated by summing the value of the data on the line, excluding the leading colon and checksum byte itself, and taking its two's complement. For example, the line: :0300300002337A1E Breaking this line into it's components we have: Record Length: 03 (3 bytes of data) Address: 0030 (the 3 bytes will be stored at 0030, 0031, and 0032) Record Type: 00 (normal data) Data: 02, 33, 7A Checksum: 1E Taking all the data bytes above, we have to calculate the checksum based on the following hexadecimal values: 03 00 30 00 02 33 7A = E2 The two's complement of E2 is 1E which is, as you can, the checksum value. For those unfamiliar with calculating a two's complement, it's quite simple: The two's complement of a number if the value which must be added to the number to reach the value 256 (decimal). That is to say, E2 1E = 100. You may also calculate the two's complement by subtracting the value from 100h. In other words, 100h - E2h = 1Eh -- which is the checksum. If the value in question is greater than FFh, simply take the part which is less than 100h. For example, if you want the two's complement of the value 494h, simply drop the leading "4" which leaves you with 94h. The two's complement of 94h is 6Ch. 發表人 - frederick 於 2003/05/24 13:33:38
kevinhue
一般會員


發表:23
回覆:42
積分:13
註冊:2003-05-06

發送簡訊給我
#4 引用回覆 回覆 發表時間:2003-05-27 10:25:14 IP:218.160.xxx.xxx 未訂閱
請問一下,Function FBinFromHex() 這個要怎麼用ㄚ??我是用BCB6.0板的......都找不到說明檔                            感恩....
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#5 引用回覆 回覆 發表時間:2003-05-27 13:05:39 IP:140.135.xxx.xxx 未訂閱
kevinhue您好:   我的是BCB5.0版   在[Help]->[WindowsDSK]裡查的到    順心 <>~我也是在學習的階段,所以請您多多見諒與指教~
kevinhue
一般會員


發表:23
回覆:42
積分:13
註冊:2003-05-06

發送簡訊給我
#6 引用回覆 回覆 發表時間:2003-05-27 13:31:06 IP:218.160.xxx.xxx 未訂閱
請問一下要怎麼寫ㄚ???有點看不懂ㄟ??
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#7 引用回覆 回覆 發表時間:2003-05-27 13:38:24 IP:140.135.xxx.xxx 未訂閱
kevinhue您好:    假如這FUNCTION是您要的話,那再看看MSDN的說明,看看有沒有幫助    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/mapi/html/_mapi1book_fbinfromhex.asp 順心 <>~我也是在學習的階段,所以請您多多見諒與指教~ 發表人 -
turboted
版主


發表:95
回覆:754
積分:452
註冊:2002-07-23

發送簡訊給我
#8 引用回覆 回覆 發表時間:2003-05-27 14:02:45 IP:61.30.xxx.xxx 未訂閱
BCB可以直接用,但HELP ON-LINE 查不到 你要在CODE裏面直接輸入 HexToBin( 就會出現參數說明 function HexToBin(Text, Buffer: PChar; BufSize: Integer): Integer     delphi 使用 HexToBin BinToHex 互轉 原文出處 http://www.blong.com/Conferences/DCon99/VCLSourcery/VCLSourcery.htm    
Listing 8: Using BinToHex and HexToBin    //Buffer is binary data,
//Text is target text buffer (assumed to be big enough),
//BufSize is size of binary data block
//procedure BinToHex(Buffer, Text: PChar; BufSize: Integer);    //Text is textual representation of binary data,
//Buffer is target binary data buffer
//BufSize is size of textual data buffer
//function HexToBin(Text, Buffer: PChar; BufSize: Integer): Integer;    procedure TForm1.Button1Click(Sender: TObject);
var
  E: Extended;
  //Make sure there is room for null terminator
  Buf: array[0..SizeOf(Extended) * 2] of Char;
begin
  E := Pi;
  Label1.Caption := Format('E starts off as %.15f', [E]);
  BinToHex(@E, Buf, SizeOf(E));
  //Slot in the null terminator for the PChar, so we can display it easily
  Buf[SizeOf(Buf) - 1] := #0;
  Label2.Caption := Format('As text, the binary contents of E look like %s', [Buf]);
  //Translate just the characters, not the null terminator
  HexToBin(Buf, @E, SizeOf(Buf) - 1);
  Label3.Caption := Format('Back from text to binary, E is now %.15f', [E]);
end;    
taishyang
站務副站長


發表:377
回覆:5490
積分:4563
註冊:2002-10-08

發送簡訊給我
#9 引用回覆 回覆 發表時間:2003-05-27 14:18:34 IP:140.135.xxx.xxx 未訂閱
我補充C++的範例   http://www.expertsexchange.com/Programming/Programming_Languages/Cplusplus/Q_20169213.html 順心 <>~我也是在學習的階段,所以請您多多見諒與指教~ 發表人 -
系統時間:2024-04-29 7:21:47
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!