Word size and endianness:
char
is:
Arrays are:
Strings are:
Allocate memory:
This toy is a model of how a low-level programming language might use a computer's memory.
Hover over a memory location to see its address. Click on a memory location to directly edit the data stored there. Use the randomise button to randomly corrupt the memory table — why not?
You can allocate memory for variables by clicking on the appropriate buttons. Each variable corresponds with a coloured box on the memory table, showing which memory location(s) are used to store that variable. The variables panel also shows a more abstract view of which variables exist, and their types, memory addresses, and values.
To change the value of a variable, simply type a new value in the input box in the variables panel, and press Enter. The following types of values are allowed:
byte
: an 8-bit signed integer.short
: a 16-bit signed integer.int
: an 32-bit signed integer.boolean
: a single true
or false
value.char
: a single character; by default, the extended ASCII encoding (ISO 8859-1) is used.pointer
: a reference to a memory location (e.g. @4D
), or null
. Pointers can also be assigned like &x
for the address of a variable named x
.You can also allocate strings, arrays, and structs. To define a struct type, list its component types separated by semicolons. Details about allocated strings, arrays and structs appear in the objects panel; their values can also be edited here.
Raw data is always shown in hexadecimal format. Values which span multiple memory locations are in little-endian format by default, so e.g. the 32-bit integer 0x12345678
will be stored as 78 56 34 12
with an 8-bit word size, or 5678 1234
with a 16-bit word size.
The show allocated regions checkbox controls whether allocated regions are shown in an overlay upon the memory table. The show meaningful values checkbox will enable additional higher-level information in this overlay, which is especially useful for pointers.
The reset button will de-allocate all memory and initialise it with zero-values. Press the settings button to change details about the machine model; you can choose the word size (the number of bits per memory location), change the representation of arrays and strings, or change the memory allocation strategy.