updating oE poke2

poke2

<built-in> procedure poke2(atom addr, object x) 

stores one or more words, starting at a memory location.

Parameters:
  1. addr : an atom, the address at which to store
  2. x : an object, either a word or a non empty sequence of words.
Errors:

Poking 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.

Comments:

There is no point in having poke2s or poke2u. For example, both 32768 and -32768 are stored as #F000 when stored as words. It is up to whoever reads the value to figure it out.

It is faster to write several words at once by poking a sequence of values, than it is to write one words at a time in a loop.

Writing to the screen memory with poke2 can be much faster than using puts or printf, but the programming is more difficult. In most cases the speed is not needed. For example, the Euphoria editor, ed, never uses poke2.

The 2-byte values to be stored can be negative or positive. You can read them back with either peek2s or peek2u. Actually, only remainder(x,65536) is being stored.

Example 1:
 a = allocate(100)   -- allocate 100 bytes in memory 
 
-- poke one 2-byte value at a time: 
poke2(a, 12345) 
poke2(a+2, #FF00) 
poke2(a+4, -12345) 
 
-- poke 3 2-byte values at once: 
poke2(a, {12345, #FF00, -12345}) 
See Also:

Using Data Words, peek2s, peek2u, poke, poke4, allocate, free

Not Categorized, Please Help

Search



Quick Links

User menu

Not signed in.

Misc Menu