open BitVectors;; open Physical;; exception CodeTooLarge type time = int;; type line = [ `P1 of byte | `P3 of byte | `SerialBuff of [ `Eight of byte | `Nine of BitVectors.bit * byte ] ];; val string_of_line: line -> string;; type epsilon = int;; (* In: reception time, line of input, new continuation, Out: transmission time, output line, expected duration until reply, new continuation. *) type continuation = [`In of time * line * epsilon * continuation] option * [`Out of (time -> line -> time * continuation) ];; type status = { (* Memory *) code_memory: WordMap.map; (* can be reduced *) low_internal_ram: Byte7Map.map; high_internal_ram: Byte7Map.map; external_ram: WordMap.map; (* Program counter *) pc: word; (* SFRs *) sp: byte; dpl: byte; dph: byte; pcon: byte; tcon: byte; tmod: byte; tl0: byte; tl1: byte; th0: byte; th1: byte; p1: byte; scon: byte; sbuf: byte; ie: byte; p3: byte; ip: byte; psw: byte; acc: byte; b: byte; t2con: byte; (* 8052 only *) rcap2l: byte; (* 8052 only *) rcap2h: byte; (* 8052 only *) tl2: byte; (* 8052 only *) th2: byte; (* 8052 only *) (* Latches for the output lines *) p1_latch: byte; p3_latch: byte; (* Fields for tracking the state of the processor. *) (* IO specific *) previous_p1_val: bool; previous_p3_val: bool; serial_epsilon_out: epsilon option; serial_epsilon_in: epsilon option; io_epsilon: epsilon; serial_v_in: [`Eight of byte | `Nine of (BitVectors.bit * byte) ] option; serial_v_out: [`Eight of byte | `Nine of (BitVectors.bit * byte) ] option; serial_k_out: continuation option; io: continuation; expected_out_time: [ `None | `Now | `At of time ]; (* Timer and clock specific *) clock: time; timer0: word; timer1: word; timer2: word; (* can be missing *) esi_running: bool; t0i_running: bool; t1i_running: bool; e0i_running: bool; e1i_running: bool; es_running: bool; exit_addr : BitVectors.word; cost_labels : string BitVectors.WordMap.t } val string_of_status: status -> string val assembly: [< ASM.labelled_instruction] ASM.pretty_program -> ASM.program (* val link: (ASM.instruction list * symbol_table * cost_map) list -> BitVectors.byte list *) val initialize: status val load_code_memory: BitVectors.byte list -> Physical.WordMap.map val load_mem: Physical.WordMap.map -> status -> status val load: BitVectors.byte list -> status -> status exception Halt (* to be raised to stop execution *) (* the callback function is used to observe the execution trace; it can raise Hold to stop execution. Otherwise the processor never halts. *) val execute: (status -> unit) -> status -> status val fetch: Physical.WordMap.map -> word -> ASM.instruction * word * int val load_program : ASM.program -> status val interpret : bool -> ASM.program -> AST.trace val size_of_instrs : ASM.labelled_instruction list -> int