peek4( addr, [n] )
- Reads one or more 32-bit fixed-point number values from contiguous groups of four consecutive memory locations.
- addr
-
- The address of the first memory location.
- n
-
- The number of values to return. (1 by default, 32767 max.)
The peek4()
function reads and returns 32-bit values from groups of four consecutive bytes in the addressable memory region (0x0000-0x7fff). The value is interpreted in the Little Endian representation, which stores the lowest 8 bits of the fractional part in the first byte, and the lowest 8 bits of the integer part in the third byte.
See Memory for information about the memory layout.
$ operator[]
The unary-$
operator added in 0.2.0 performs the same function as peek4(address)
and is now the recommended way to read one 32-bit word of memory at a time, as it uses fewer tokens, costs fewer cycles at runtime, and runs on the real host CPU much more efficiently. Simply replace peek4(address)
with $address
.
Examples[]
poke(0x4300, 0x00, 0xc0, 0xff, 0x0f)
b = peek4(0x4300) -- 0x0fff.c000, or 4095.75 in decimal
b = $0x4300 -- preferred method