Changeset 443


Ignore:
Timestamp:
Jan 13, 2011, 11:35:18 AM (9 years ago)
Author:
mulligan
Message:

Wrote exportation code. Need to test it.

Location:
Deliverables/D4.1
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D4.1/IntelHex.ml

    r442 r443  
    195195     unitialized zone in the code memory.
    196196*)
    197 let export_intel_hex chunk_size max_addressable code_mem =
    198   let rec aux chunk_size address rbuff lbuff =
     197let export_code_memory chunk_size max_addressable code_mem =
     198  let rec aux chunk_size address start_address rbuff lbuff =
    199199    if chunk_size = 0 or address = max_addressable then
    200200      lbuff
     
    202202      let code = Physical.WordMap.find (vect_of_int address `Sixteen) code_mem in
    203203        if code = zero `Eight then
    204           aux chunk_size (address + 1) [] (rbuff::lbuff)
     204          aux chunk_size (address + 1) address [] ((start_address, rbuff)::lbuff)
    205205        else
    206           aux (chunk_size - 1) (address + 1) (code::rbuff) lbuff
     206          aux (chunk_size - 1) (address + 1) start_address (code::rbuff) lbuff
    207207  in
    208     aux chunk_size 0 [] []
     208    aux chunk_size 0 0 [] []
     209;;
     210
     211let clean_exported_code_memory = List.filter (fun x -> snd x <> [])
     212;;
     213
     214let process_exported_code_memory =
     215  List.map (fun x ->
     216    { record_length = vect_of_int (List.length (snd x)) `Eight;
     217      record_addr = vect_of_int (fst x) `Sixteen;
     218      record_type = Data;
     219      data_field = snd x;
     220      data_checksum = zero `Eight (* for the time being *)
     221    })
     222;;
     223
     224let pack_exported_code_memory chunk_size max_addressable code_mem =
     225  let export = export_code_memory chunk_size max_addressable code_mem in
     226  let cleaned = clean_exported_code_memory export in
     227  let processed = process_exported_code_memory cleaned in
     228  let end_buffer =
     229    [{ record_length = zero `Eight;
     230      record_addr = zero `Sixteen;
     231      record_type = End;
     232      data_field = [];
     233      data_checksum = zero `Eight
     234    }] in
     235    processed @ end_buffer
     236;;
  • Deliverables/D4.1/IntelHex.mli

    r442 r443  
    1212val intel_hex_of_file: string -> intel_hex_format
    1313val process_intel_hex: intel_hex_format -> Physical.WordMap.map
    14 val export_intel_hex: int -> int -> Physical.WordMap.map -> byte list list
     14
     15val pack_exported_code_memory: int -> int -> Physical.WordMap.map -> intel_hex_format
Note: See TracChangeset for help on using the changeset viewer.