poke

Definition: poke(atom a, object x)
Description: If x is an atom, write a single byte value to memory address a.

If x is a sequence, write a sequence of byte values to consecutive memory locations starting at location a.

There are in fact 5 other variations of the poke routine:

      poke1  poke2  poke4  poke8  pokeN

which write byte/word/dword/qword value(s) to memory. The poke procedure is an alias of poke1. The pokeN routine has 3 parameters: address, value, and size(1|2|4|8).
Comments: For poke (/poke1) the lower 8 bits of each byte value, i.e. and_bits(x, #FF), are stored in memory, and likewise for poke2/4/8, the lower 16/32/64 bits of each word/dword/qword value.

The poke8 function is only intended for use on 64-bit architectures; see the Technicalia drop-down below for more details.

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

Example:
a = allocate(100)   -- allocate 100 bytes in memory
-- poke one byte at a time:
poke(a,97)
poke(a+1,98)
poke(a+2,99)
-- poke 3 bytes at once:
poke(a,{97,98,99})
See Also: safe_poke, peek, allocate, free, call, safe.e