Main Index : Reference :

mem2uword()


Description

Converts a 16 bit unsigned short int word at a certain position in a byte array into a C.O.F.F.E.E. integer.

Definition

[int] mem2uword([bytes] mem,[int] pos,[int] byteorder)

Parameters

mem is a byte array.
pos is the position within mem.
byteorder is either big endian or little endian.

Return Value

mem2uword() converts 2 bytes from position pos in the byte array mem as a 16 bit unsigned short int word and returns the result as an integer value. The byte ordering is decided by the value of the byteorder parameter:

Value Platform Byte ordering
GE_MOTOROLA Motorola big endian
GE_INTEL Intel little endian

Remember: The first element of a byte array is at position 0.

Example

// Outputs "0xF00B = 61451
//          0x0BF0 = 3056".

var mem = new(bytes,2);

mem[0] = 0xF0;
mem[1] = 0x0B;

var motorola = mem2uword(mem,0,GE_MOTOROLA);
var intel = mem2uword(mem,0,GE_INTEL);

println("0xF00B = ",motorola);
println("0x0BF0 = ",intel);

See Also

[bytes], mem2word(), mem2long(), mem2iee(), mem2liee(), word2mem(), uword2mem(), long2mem(), iee2mem(), liee2mem()