Skip to content

Structure

Trevor Brunette edited this page Apr 1, 2023 · 5 revisions

Summary

EzASM is a Register-based language which runs on a simulated CPU.

4-byte words (32-bit) are used by default, however this can be configured to instead be 8-byte words (64-bit).

Memory Space Diagram

0x0 - 0x3_FFFF 0x4_0000 - 0x7_FFFF 0x8_0000 - - 0x8F_FFFF
Reserved Memory String Read-Only Initial Heap Pointer Initial Stack Pointer

The read-only reserved memory location is from address 0x0 to 0x3_FFFF by default. Its size is calculated by word size * 0x1_0000. This memory represents system storage. It is not actually used for anything, but it should exist just so that accesses to memory near 0 cause an error.

The string read-only memory is another reserved portion of memory that only supports read operations. It ranges from 0x4_0000 to 0x7_FFFF by default. Its size is calculated by word size * 0x1_0000. Any write operation to this section will cause an error. This memory section stores string immediates defined in the source code.

The heap pointer begins directly after the string read-only memory. By default, this beginning is at 0x8_0000 and the end is 0x7F_FFFF. Its size is calculated by word size * 0x20_0000. The heap and stack occupy the same space in memory. The heap grows "upward" towards the stack when it is allocated to. The stack, on the other hand, grows "downward" towards the heap. It is possible for these to collide if the program allocates too much memory to the stack or heap.

The stack pointer begins at the end of the space allocated for the heap: 0x7F_FFFF by default. The stack/heap space can be calculated by word size * 0x20_0000. Since the stack and heap occupy the same space in memory, it is important to understand that, if grown too much, the stack and heap will collide and overwrite values from each other. Most modern programming languages and operating systems have features in-place to prevent such a collision, but not all assembly languages do -- this one does not (yet).

Clone this wiki locally