Skip to content
This repository was archived by the owner on Nov 11, 2021. It is now read-only.

Conversation

@ap29600
Copy link
Contributor

@ap29600 ap29600 commented Oct 9, 2021

A simple operation that pushes a pointer to the element that is currenlty on the top of the stack.

With this functionality it's possible to allocate a temporary buffer on the stack by repeatedly pushing 0, and this enables to implement putd without a static buffer in memory, so putd can now be in the standard library.

As a sidenote, building gol.porth will now fail due to the macro name collision.

There is one drawback, and that is that this will create a discrepancy between simulation and compilation, as there is no easy way to implement this in python I think.
Assuming that the stack is contiguous in memory in the bootstrapped version, there should really be no problem after that.

ap29600 and others added 5 commits October 9, 2021 22:41
the ref operation pushes a pointer to the variable that is currently on
the top of the stack. (Only works in compilation mode, but it sould be
trivial to implement it in simulation mode if real pointers are used
for `mem` after the bootstrapping.)
@mjdr
Copy link

mjdr commented Oct 10, 2021

Stack should be used for storing values that size know in compile time.
ref introduces value aliasing and makes static analysis useless

@Domkeykong
Copy link

you can alternatively call the mmap syscall and get some memory, this is obviously a bit overkill but unless there isnt any malloc functionality this is the only way to not clobber any memory. Also don forget to call munmap

@ap29600
Copy link
Contributor Author

ap29600 commented Oct 10, 2021

yep, makes sense to me.

@ap29600 ap29600 closed this Oct 10, 2021
@mjdr
Copy link

mjdr commented Oct 10, 2021

here another way you can implement putd without mem
#126

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants