Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Command suggestion] it's free real estate [number/register] #75

Open
kammt opened this issue Jun 19, 2022 · 4 comments
Open

[Command suggestion] it's free real estate [number/register] #75

kammt opened this issue Jun 19, 2022 · 4 comments
Labels
enhancement New feature or request new command Ah, I see you're a man of culture as well!

Comments

@kammt
Copy link
Owner

kammt commented Jun 19, 2022

Command Syntax: (e.g. stonks [register])
it's free real estate [register/number]

Command Description:
Allocates the provided number of Bytes on the Heap and returns a pointer to the starting address. If the allocation failed, 0 is returned. The memory block cannot be freed - because who does that anyway? (hides)

Which x86_64 Assembly instruction(s) would be used to translate this command?
For a possible implementation, see https://github.com/xarantolus/memeasm/blob/main/malloc/malloc.memeasm

What could this command be useful for?
Well.. heap allocation

What Meme is your command based on? (You can also provide a link to e.g. its KnowYourMeme page)
https://knowyourmeme.com/memes/its-free-real-estate

@kammt kammt added enhancement New feature or request new command Ah, I see you're a man of culture as well! labels Jun 19, 2022
@xarantolus
Copy link
Contributor

xarantolus commented Jun 19, 2022

There's also an x86-64 implementation here, the MemeAssembly version was translated from it.

One thing to note is error handling: the implementation detects if we didn't get any more memory at all (old break == new break), but it doesn't check if we got enough memory (not sure if the kernel would ever return less than we expected instead of the old break, indicating error). Maybe one should do that for a better implementation, or we just follow the MemeAseembly standard in that case

@aengelke
Copy link
Contributor

When using a libc (which we do, the programs start at main), using brk is extremely likely to break things. Why not just call... malloc? Otherwise, mmap could be used for memory allocation.

@kammt
Copy link
Owner Author

kammt commented Jun 20, 2022

using brk is extremely likely to break things

Ah, that's why the syscall is called brk :flushy:

@aengelke
Copy link
Contributor

brk is literally the abbreviation for "break" ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request new command Ah, I see you're a man of culture as well!
Projects
None yet
Development

No branches or pull requests

3 participants