Module AsmUtil

module AsmUtil: sig .. end
Assembly parsing utilities

type bits 
A bit source to use with functional IO

Creating bit sources

val bits : int64 array -> bits
Build a bit source from an array of 32-bit integers, represented with extra bits.
val read_from_channel : Pervasives.in_channel -> bits
val read_from_file : string -> bits
Create a bit source from a channel or a filename.

Basic input

val more : bits -> bool
Are there any bits left to read from this source?
val get_byte : bits -> int
What byte number in the source we have already read upto
val skip : bits -> int -> bits
Skip ahead a number of bits

Reading integers

val read_uint : bits -> int -> int * bits
val read_int : bits -> int -> int * bits
Read the specified number of bits from a bit source, returning the unsigned or signed integer we've read and the modified bit source. This won't cross 32-bit word boundaries.
val read_uint32 : bits -> int -> int64 * bits
val read_uint32_extend : bits -> int -> int64 * bits
val read_int32 : bits -> int -> int64 * bits
We take the easy way out and use int64 here so that we can use the same type for both signed and unsigned values. The difference between the first two is that read_uint32 zero-extends, while read_uint32_extend sign-extends.
val read_string : bits -> string * bits
Read a zero-terminated string.