source: Deliverables/D4.1/Byte.ml @ 62

Last change on this file since 62 was 62, checked in by mulligan, 10 years ago

Many additions to Bit, Nibble and Byte API, as well as more instructions
added to ASMInterpret execute function.

File size: 1.6 KB
Line 
1(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
2(* FILENAME: Byte.ml                                                         *)
3(* DESCRIPTION: An ADT implementing bytes, and common operations on them.    *)
4(* CREATED: 10/09/2010, Dominic Mulligan                                     *)
5(* BUGS:                                                                     *)
6(*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*^*)
7
8open Bit;;
9open Nibble;;
10
11module type BYTE =
12sig
13  type bit
14  type nibble
15  type byte
16(*
17  val from_bits: bit -> bit -> bit -> bit -> bit -> bit -> bit -> bit -> byte
18  val from_nibbles: nibble -> nibble -> byte
19  val from_int: int -> byte
20
21  val get_nibble_at: int -> byte -> nibble
22  val set_nibble_at: int -> nibble -> byte -> byte option
23  val get_bit_at: int -> byte -> bit
24  val set_bit_at: int -> bit -> byte -> byte option
25
26  val (-&-): byte -> byte -> byte
27  val (-|-): byte -> byte -> byte
28  val (-^-): byte -> byte -> byte
29  val not: byte -> byte
30
31  val map_nibble: (nibble -> nibble) -> byte -> byte
32  val map_bit: (bit -> bit) -> byte -> byte
33  val iter_nibble: (nibble -> string) -> byte -> string
34  val iter_bit: (bit -> string) -> byte -> string
35  val zip_nibble: (nibble -> nibble -> nibble) -> byte -> byte -> byte
36  val zip_bit: (bit -> bit -> bit) -> byte -> byte -> byte
37  val pretty: byte -> string
38*)
39end
40
41module Byte(Nibble: NIBBLE): BYTE
42  with type bit = Nibble.bit and type nibble = Nibble.nibble =
43struct
44  type bit = Nibble.bit
45  type nibble = Nibble.nibble
46  type byte = nibble * nibble
47end
Note: See TracBrowser for help on using the repository browser.