Ignore:
Timestamp:
Nov 4, 2011, 12:22:17 PM (8 years ago)
Author:
ayache
Message:

Function pointers in D2.2/8051. Bugged for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Deliverables/D2.2/8051/src/ASM/ASMInterpret.ml

    r1462 r1488  
    10361036             List.flatten (List.map assembly1 translation)
    10371037      | `Mov (`DPTR,s) ->
    1038           let addrr16 = StringTools.Map.find s datalabels in
    1039            assembly1 (`MOV (`U4 (`DPTR,`DATA16 addrr16)))
     1038          (* let addr16 = StringTools.Map.find s datalabels in *)
     1039          let addrr16 =
     1040            try StringTools.Map.find s datalabels
     1041            with Not_found -> StringTools.Map.find s labels in
     1042          assembly1 (`MOV (`U4 (`DPTR,`DATA16 addrr16)))
    10401043      | `Jmp s ->
    10411044          let pc_offset = StringTools.Map.find s labels in
     
    20052008    (res, List.rev !trace)
    20062009  else (IntValue.Int32.zero, [])
     2010
     2011
     2012let size_of_instr instr =
     2013  let exit_lbl = "exit" in
     2014  let p = { ASM.ppreamble = [] ; ASM.pexit_label = exit_lbl ;
     2015            ASM.pcode = [instr ; `Label exit_lbl] ; ASM.phas_main = false } in
     2016  let p = assembly p in
     2017  let status = load_program p in
     2018  let addr_zero = BitVectors.vect_of_int 0 `Sixteen in
     2019  let (_, size, _) = fetch status.code_memory addr_zero in
     2020  BitVectors.int_of_vect size
     2021
     2022let size_of_instrs instrs =
     2023  let f res instr = res + (size_of_instr instr) in
     2024  List.fold_left f 0 instrs
Note: See TracChangeset for help on using the changeset viewer.