source: Deliverables/D4.1/IntelHex.ml @ 123

Last change on this file since 123 was 123, checked in by mulligan, 9 years ago

IntelHex? file modified: string_of_intel_hex_entry implemented.

File size: 1010 bytes
Line 
1open BitVectors;;
2open ASM;;
3
4type intel_hex_entry_type =
5    Data
6  | End
7  | ExtendedSeg
8  | ExtendedLinear
9
10type intel_hex_entry =
11{
12  record_length: byte * byte;
13  record_type: intel_hex_entry_type;
14  data_field: byte list;
15  data_checksum: byte * byte
16};;
17
18let hex_string_of_vect x = "00"
19
20let string_of_intel_hex_entry entry =
21  let record_length_l, record_length_r = entry.record_length in
22  let data_checksum_l, data_checksum_r = entry.data_checksum in
23  let length_string = hex_string_of_vect record_length_l ^ 
24                      hex_string_of_vect record_length_l in
25  let checksum_string = hex_string_of_vect data_checksum_l ^ 
26                        hex_string_of_vect data_checksum_r in
27  let type_string =
28    match entry.record_type with
29      Data -> "00"
30    | End -> "01"
31    | ExtendedSeg -> "02"
32    | ExtendedLinear -> "04" in
33  let data_string = String.concat "" (List.map hex_string_of_vect entry.data_field) in
34    ":" ^ length_string ^ type_string ^ data_string ^ checksum_string
Note: See TracBrowser for help on using the repository browser.