Changeset 128 for Deliverables/D4.1
- Timestamp:
- Sep 24, 2010, 1:36:41 PM (10 years ago)
- Location:
- Deliverables/D4.1
- Files:
-
- 1 added
- 1 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
Deliverables/D4.1/IntelHex.ml
r123 r128 1 1 open BitVectors;; 2 2 open ASM;; 3 open Util;; 3 4 4 5 type intel_hex_entry_type = … … 16 17 };; 17 18 18 let hex_string_of_vect x = "00" 19 let hex_string_of_int i = 20 let digit_lookup = 21 function 22 0 -> "0" | 1 -> "1" | 2 -> "2" 23 | 3 -> "3" | 4 -> "4" | 5 -> "5" 24 | 6 -> "6" | 7 -> "7" | 8 -> "8" 25 | 9 -> "9" | 10 -> "A" | 11 -> "B" 26 | 12 -> "C" | 13 -> "D" | 14 -> "E" 27 | 15 -> "F" | _ -> assert false in 28 29 let rec aux i = 30 if i < 16 then 31 digit_lookup i 32 else 33 let div = i / 16 in 34 let rem = i mod 16 in 35 aux div ^ digit_lookup rem 36 in 37 aux i 38 39 let int_of_hex_string h = 40 let digit_lookup = 41 function 42 '0' -> 0 | '1' -> 1 | '2' -> 2 43 | '3' -> 3 | '4' -> 4 | '5' -> 5 44 | '6' -> 6 | '7' -> 7 | '8' -> 8 45 | '9' -> 9 | 'A' -> 10 | 'B' -> 11 46 | 'C' -> 12 | 'D' -> 13 | 'E' -> 14 47 | 'F' -> 15 | _ -> assert false in 48 49 let rec aux l p = 50 match l with 51 [] -> 0 52 | hd::tl -> 53 digit_lookup hd * p + aux tl (p * 16) 54 in 55 aux (List.rev $ char_list_of_string h) 1 56 57 let hex_string_of_vect v = 58 let vect_int = int_of_vect v in 59 hex_string_of_int vect_int 19 60 20 61 let string_of_intel_hex_entry entry =
Note: See TracChangeset
for help on using the changeset viewer.