ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to implement a heap that is truely dynamic in nasm. I'm having some trouble. I'm not sure whether I'm clobbering something else on the system or not.
Do you know the structure of a stack on the x86? That's essensially the same structure I'm trying to create. I can't just use the actual stack and some pointers, because it'd be too slow. I'd have to move the actual stack constantly!
So instead, I have to start by creating the stack. I have 3 basic functions. 1 is put, another is get, and the last is read. They come in two varieties: heap_heap, and heap.
The heap heap stores addresses of all the heaps, but works otherwise just like a normal heap. So when you want to pick something from a heap, you use the pointer provided from looking on the heap heap.
put puts things on the heap. read reads what's on a heap. get calls read, and then removes the thing on the heap.
Now this is a heap, not a stack. The real difference between a heap and a stack in this case is that this structure has an offset variable. The offset variable can be set for positive or negative, and a value. Then when you read or get, you read or get from that offset. This works by adding the offset, to the value. Of course, adding a negative is the same as subtracting, so it's below the current point if you use a negative, and above if you use a positive.
I suspect that the reason you haven't gotten any useful answer to your question is that it's so open-ended.
When I read your second sentence, it seems that you've already started implementing this thing, and you're debugging it, and the debugging is not going well.
I suspect that people on LQ are too busy to slow down and fully understand what you wrote about the design of your heap. I know that I'm too busy!
If you're just dealing with your own process's memory, you are unlikely to be "clobbering something else on the system".
Beyond that, it might be that the debugging of your heap is a task for you alone. If you find something that's truly puzzling, and you can reproduce it in a simple, tiny example, so that all that design stuff is irrelevant, perhaps you can post that, and perhaps people can and will jump in and help cheerfully.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.