Ignore:
Timestamp:
Mar 2, 2011, 3:27:41 PM (9 years ago)
Author:
ayache
Message:

Update of D2.2 from Paris.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/LIN/LINInterpret.ml

    r486 r619  
    4242      renv   : hdw_reg_env ;
    4343      mem    : memory ;
    44       trace  : AST.trace }
     44      trace  : CostLabel.t list }
    4545
    4646
     
    195195  match Mem.find_fun_def st.mem ptr with
    196196    | LIN.F_int def ->
    197 (*
    198       Printf.printf "Pushing return address in IRAM: %s\n%!"
    199         (Val.to_string (next_pc st).pc) ;
    200 *)
    201197      let st = save_ra st in
    202198      init_fun_call st ptr
     
    205201let interpret_return st =
    206202  let pc = return_pc st in
    207 (*
    208   Printf.printf "Returning to %s\n%!" (Val.to_string pc) ;
    209 *)
    210203  change_pc st pc
    211204
     
    328321  Printf.printf "\n%!"
    329322
    330 let print_result st =
    331   let string_of_reg r = Val.to_string (get_reg r st) in
    332   Printf.printf "DPH: %s - DPL: %s\n%!"
    333     (string_of_reg I8051.dph) (string_of_reg I8051.dpl)
    334 
    335 let rec iter_small_step st =
     323let compute_result st =
     324  let v = get_reg I8051.dpl st in
     325  if Val.is_int v then IntValue.Int8.cast (Val.to_int_repr v)
     326  else IntValue.Int8.zero
     327
     328let rec iter_small_step print_result st =
    336329(*
     330  (* <DEBUG> *)
    337331  print_state st ;
     332  (* </DEBUG> *)
    338333*)
    339334  match fetch_stmt st with
    340335    | LIN.St_return when Val.eq (return_pc st) Val.zero ->
    341 (*
    342       print_state st ;
    343       print_result st ;
    344 *)
    345       List.rev st.trace
     336      let (res, cost_labels) as trace =
     337        (compute_result st, List.rev st.trace) in
     338      if print_result then
     339        Printf.printf "LIN: %s\n%!" (IntValue.Int8.to_string res) ;
     340      trace
    346341    | stmt ->
    347342      let st' = interpret_stmt st stmt in
    348       iter_small_step st'
     343      iter_small_step print_result st'
    349344
    350345
     
    406401   - Initialize the carry flag to 0. *)
    407402
    408 let interpret p = match p.LIN.main with
    409   | None -> []
     403let interpret print_result p = match p.LIN.main with
     404  | None -> (IntValue.Int8.zero, [])
    410405  | Some main ->
    411406    let st = empty_state in
     
    416411    let st = init_main_call st main in
    417412    let st = change_carry st Val.zero in
    418     iter_small_step st
     413    iter_small_step print_result st
Note: See TracChangeset for help on using the changeset viewer.