initial import

This commit is contained in:
Lobo 2025-11-27 16:39:54 -03:00
commit ad589d2894
26 changed files with 2241 additions and 0 deletions

36
lib/Machine.mli Normal file
View file

@ -0,0 +1,36 @@
type stack = Stack of { data : bytes; mutable sp : int }
type mode = Mode of { short : bool; keep : bool; mutable temp : int }
val stack_create : unit -> stack
val peek : mode -> stack -> int
val pop : mode -> stack -> int
val push : mode -> stack -> int -> unit
val pushbyte : mode -> stack -> int -> unit
val pushshort : mode -> stack -> int -> unit
val popbyte : mode -> stack -> int
val popshort : mode -> stack -> int
type machine
val ram : machine -> bytes
val dev : machine -> bytes
val wst : machine -> stack
val rst : machine -> stack
val stack : machine -> bool -> stack
type machine_state = Break | Next of int
type _ Effect.t +=
| BRK : int Effect.t (* Returns a new PC if handled *)
| DEI : int -> int Effect.t
| DEI2 : int -> int Effect.t
| DEO : (int * int) -> unit Effect.t
val create : string -> machine
val dispatch :
?dbg:(machine -> Instr.t -> int -> unit) option ->
?cycles:int ->
machine ->
int ->
unit