immortalvm / ivm-implementations

iVM contemporary implementations
5 stars 0 forks source link

native instructions allocate/deallocate not available #7

Closed elnv closed 4 years ago

elnv commented 4 years ago

Although C compiler does not generate instructions allocate/deallocate they should be available to library developers, as it can be necessary to build library functions such as malloc().

In version 0.15 they are not apparently supported. Old github examples using these instructions have stopped working.

We think that all native instructions should be visible for the assembly programmer, in addition to syntax sugars.

ivar-rummelhoff commented 4 years ago

There are no longer primitive/native instructions for allocation and de-allocation. Instead, we want to leave this to libc.

elnv commented 4 years ago

So, can we access now all memory positions without allocating them previously? Where is the HEAP then? Is there any memory map available with the use of different positions?

ivar-rummelhoff commented 4 years ago

When the machine starts, the PC points to the first available memory location, and the SP point to the address after the last available memory location. The code prepended to every program stores the address to the start of the heap in the last 8 bytes before the program itself, see intro3_advanced.s. Hopefully, libc will handle the memory mapping.