Ignore:
Timestamp:
Oct 11, 2011, 5:42:20 PM (9 years ago)
Author:
tranquil
Message:
  • changed implementation of constant indexings with extensible arrays
  • work on ASM completed
  • next: optimizations!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051-indexed-labels-branch/src/ASM/Pretty.ml

    r1349 r1357  
    4343 function
    4444    `Label l -> l ^ ":"
    45                 (* ugly-printing *)
    46   | `Cost l -> CostLabel.string_of_cost_label l ^ ":"
     45  | `Cost l -> CostLabel.string_of_cost_label ~pretty:true l ^ ":"
    4746        | `Index i -> "index " ^ string_of_int i ^ ":"
    4847  | `Inc i -> "increment " ^ string_of_int i ^ ":"
     
    9998  | `XRL(`U2(a1,a2)) -> "xrl   " ^ pp_arg a1 ^ ", " ^ pp_arg a2
    10099
     100let find_comment p pc =
     101        let s1 =
     102                try
     103                        let lbl = BitVectors.WordMap.find pc p.ASM.cost_labels in
     104      ", " ^ CostLabel.string_of_cost_label ~pretty:true lbl
     105    with Not_found -> "" in
     106        let s2 =
     107    try
     108      let i = BitVectors.WordMap.find pc p.ASM.inds in
     109      ", index " ^ string_of_int i
     110    with Not_found -> "" in
     111        let s3 =
     112    try
     113      let i = BitVectors.WordMap.find pc p.ASM.incs in
     114      ", inc " ^ string_of_int i
     115    with Not_found -> "" in
     116        s1 ^ s2 ^ s3
     117                       
     118
    101119let print_program p =
    102120  let mem = ASMInterpret.load_code_memory p.ASM.code in
    103121  let f (s, pc) _ =
    104122    let (inst, new_pc, cost) = ASMInterpret.fetch mem pc in
    105     (Printf.sprintf "%s% 6X:  %- 18s ;; %d  %s\n"
     123    (Printf.sprintf "%s% 6X:  %- 18s ;; %d%s\n"
    106124       s
    107125       (BitVectors.int_of_vect pc)
    108126       (pp_instruction inst)
    109127       cost
    110        (if BitVectors.WordMap.mem pc p.ASM.cost_labels then
    111                                  let lbl = BitVectors.WordMap.find pc p.ASM.cost_labels in
    112                CostLabel.string_of_cost_label ~pretty:true lbl
    113               else ""),
     128                         (find_comment p pc),
    114129     new_pc) in
    115130  fst (List.fold_left f ("", BitVectors.zero `Sixteen) p.ASM.code)
Note: See TracChangeset for help on using the changeset viewer.