source: Deliverables/D2.2/8051/src/ASM/ASMInterpret.mli @ 486

Last change on this file since 486 was 486, checked in by ayache, 9 years ago

Deliverable D2.2

File size: 3.0 KB
Line 
1open BitVectors;;
2open Physical;;
3
4exception CodeTooLarge
5
6type time = int;;
7type line = [ `P1 of byte
8            | `P3 of byte
9            | `SerialBuff of [ `Eight of byte
10                             | `Nine of BitVectors.bit * byte
11                             ]
12            ];;
13
14val string_of_line: line -> string;;
15
16type epsilon = int;;
17
18(* In:  reception time, line of input, new continuation,
19   Out: transmission time, output line, expected duration until reply,
20        new continuation.
21*)
22type continuation =
23  [`In of time * line * epsilon * continuation] option *
24  [`Out of (time -> line -> time * continuation) ];;
25
26module IntMap: Map.S with type key = int
27type costs = CostLabel.t IntMap.t
28
29type status =
30{
31  (* Memory *)
32  code_memory: WordMap.map;        (* can be reduced *)
33  low_internal_ram: Byte7Map.map;
34  high_internal_ram: Byte7Map.map;
35  external_ram: WordMap.map;
36
37  (* Program counter *)
38  pc: word;
39
40  (* SFRs *)
41  sp: byte;
42  dpl: byte;
43  dph: byte;
44  pcon: byte;
45  tcon: byte;
46  tmod: byte;
47  tl0: byte;
48  tl1: byte;
49  th0: byte;
50  th1: byte;
51  p1: byte;
52  scon: byte;
53  sbuf: byte;
54  ie: byte;
55  p3: byte;
56  ip: byte;
57  psw: byte;
58  acc: byte;
59  b: byte;
60  t2con: byte;   (* 8052 only *)
61  rcap2l: byte;  (* 8052 only *)
62  rcap2h: byte;  (* 8052 only *)
63  tl2: byte;     (* 8052 only *)
64  th2: byte;     (* 8052 only *)
65
66  (* Latches for the output lines *)
67  p1_latch: byte;
68  p3_latch: byte;
69
70  (* Fields for tracking the state of the processor. *)
71 
72  (* IO specific *)
73  previous_p1_val: bool;
74  previous_p3_val: bool;
75
76  serial_epsilon_out: epsilon option;
77  serial_epsilon_in: epsilon option;
78
79  io_epsilon: epsilon;
80
81  serial_v_in: [`Eight of byte | `Nine of (BitVectors.bit * byte) ] option;
82  serial_v_out: [`Eight of byte | `Nine of (BitVectors.bit * byte) ] option;
83
84  serial_k_out: continuation option;
85
86  io: continuation;
87  expected_out_time: [ `None | `Now | `At of time ];
88
89  (* Timer and clock specific *)
90  clock: time;
91  timer0: word;
92  timer1: word;
93  timer2: word;  (* can be missing *)
94
95  esi_running: bool;
96  t0i_running: bool;
97  t1i_running: bool;
98  e0i_running: bool;
99  e1i_running: bool;
100  es_running: bool;
101
102  exit_pc: word option;
103  costs: costs;
104}
105
106val string_of_status: status -> string
107
108val assembly: ASM.program -> BitVectors.byte list (*ASM.instruction list * symbol_table *) * word (* exit pc *) * string IntMap.t
109
110(*
111val link:
112 (ASM.instruction list * symbol_table * cost_map) list -> BitVectors.byte list
113*)
114
115val initialize: status
116
117val load_mem: Physical.WordMap.map -> word option -> costs -> status -> status
118val load: BitVectors.byte list -> word option -> costs -> status -> status
119
120exception Halt  (* to be raised to stop execution *)
121
122(* the callback function is used to observe the execution
123   trace; it can raise Hold to stop execution. Otherwise
124   the processor never halts. *)
125val execute: (status -> unit) -> status -> status
126
127val fetch: Physical.WordMap.map -> word -> ASM.instruction * word * int
128
129val interpret : ASM.program -> AST.trace
130
131val parse_and_interpret_hex : string -> unit
Note: See TracBrowser for help on using the repository browser.