1 | open BitVectors;; |
---|
2 | open Physical;; |
---|
3 | |
---|
4 | exception CodeTooLarge |
---|
5 | |
---|
6 | type time = int;; |
---|
7 | type line = [ `P1 of byte |
---|
8 | | `P3 of byte |
---|
9 | | `SerialBuff of [ `Eight of byte | `Nine of BitVectors.bit * byte ]];; |
---|
10 | |
---|
11 | val string_of_line: line -> string;; |
---|
12 | (* In: reception time, line of input, new continuation, |
---|
13 | Out: transmission time, output line, expected duration until reply, |
---|
14 | new continuation. |
---|
15 | *) |
---|
16 | type continuation = |
---|
17 | [`In of time * line * continuation] option * |
---|
18 | [`Out of (time -> line -> time * continuation) ] |
---|
19 | |
---|
20 | type status = private |
---|
21 | { code_memory: WordMap.map; (* can be reduced *) |
---|
22 | low_internal_ram: Byte7Map.map; |
---|
23 | high_internal_ram: Byte7Map.map; |
---|
24 | external_ram: WordMap.map; (* can be reduced *) |
---|
25 | |
---|
26 | pc: word; |
---|
27 | |
---|
28 | (* sfr *) |
---|
29 | sp: byte; |
---|
30 | dpl: byte; |
---|
31 | dph: byte; |
---|
32 | pcon: byte; |
---|
33 | tcon: byte; |
---|
34 | tmod: byte; |
---|
35 | tl0: byte; |
---|
36 | tl1: byte; |
---|
37 | th0: byte; |
---|
38 | th1: byte; |
---|
39 | p1: byte; |
---|
40 | p1_latch: byte; |
---|
41 | scon: byte; |
---|
42 | sbuf: byte; |
---|
43 | ie: byte; |
---|
44 | p3: byte; |
---|
45 | p3_latch: byte; |
---|
46 | ip: byte; |
---|
47 | psw: byte; |
---|
48 | acc: byte; |
---|
49 | b: byte; |
---|
50 | t2con: byte; (* 8052 only *) |
---|
51 | rcap2l: byte; (* 8052 only *) |
---|
52 | rcap2h: byte; (* 8052 only *) |
---|
53 | tl2: byte; (* 8052 only *) |
---|
54 | th2: byte; (* 8052 only *) |
---|
55 | |
---|
56 | previous_p1_val: bool; |
---|
57 | previous_p3_val: bool; |
---|
58 | |
---|
59 | clock: time; |
---|
60 | timer0: word; |
---|
61 | timer1: word; |
---|
62 | timer2: word; (* can be missing *) |
---|
63 | expected_out_time: [ `None | `Now | `At of time ]; |
---|
64 | io: continuation |
---|
65 | } |
---|
66 | |
---|
67 | val string_of_status: status -> string |
---|
68 | |
---|
69 | module IntMap: Map.S with type key = int |
---|
70 | |
---|
71 | val assembly: |
---|
72 | ASM.assembly_program -> BitVectors.byte list (*ASM.instruction list * symbol_table *) * string IntMap.t |
---|
73 | |
---|
74 | (* |
---|
75 | val link: |
---|
76 | (ASM.instruction list * symbol_table * cost_map) list -> BitVectors.byte list |
---|
77 | *) |
---|
78 | |
---|
79 | val initialize: status |
---|
80 | |
---|
81 | val load_mem: Physical.WordMap.map -> status -> status |
---|
82 | val load: BitVectors.byte list -> status -> status |
---|
83 | |
---|
84 | exception Halt (* to be raised to stop execution *) |
---|
85 | |
---|
86 | (* the callback function is used to observe the execution |
---|
87 | trace; it can raise Hold to stop execution. Otherwise |
---|
88 | the processor never halts. *) |
---|
89 | val execute: (status -> unit) -> status -> status |
---|
90 | |
---|
91 | val fetch: Physical.WordMap.map -> word -> ASM.instruction * word * int |
---|