updating oE peek2u


<built-in> function peek2u(object addr_n_length) 

fetches an unsigned word, or some unsigned words, from an address in memory.

  1. addr_n_length : an object, either of
    • an atom addr -- to fetch one double word at addr, or
    • a pair {addr,len} -- to fetch len double words at addr

An object, either an integer if the input was a single address, or a sequence of integers if a sequence was passed. In both cases, integers returned are words, in the range 0..65535.


Peeking in memory you do not own may be blocked by the OS, and cause a machine exception. If you use the define safe these routines will catch these problems with a Euphoria error.

When supplying a {address, count} sequence, the count must not be negative.


Since addresses are 32-bit numbers on 32-bit architectures, they can be larger than the largest value of type integer (31-bits). Variables that hold an address should therefore be declared as atoms.

It is faster to read several words at once using the second form of peek than it is to read one word at a time in a loop. The returned sequence has the length you asked for on input.

Remember that peek2u takes just one argument, which in the second form is actually a 2-element sequence.

The only difference between peek2s and peek2u is how words with the highest bit set are returned. peek2s assumes them to be negative, while peek2u just assumes them to be large and positive.

Example 1:
-- The following are equivalent: 
-- first way 
Get 4 2-byte numbers starting address 100. 
s = {peek2u(100), peek2u(102), peek2u(104), peek2u(106)} 
-- second way 
Get 4 2-byte numbers starting address 100. 
s = peek2u({100, 4}) 
See Also:

Using Data Words, poke2, peek, peek2s, allocate, free peek4u

Not Categorized, Please Help


Quick Links

User menu

Not signed in.

Misc Menu