LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Heap in nasm (https://www.linuxquestions.org/questions/programming-9/heap-in-nasm-563859/)

des_a 06-22-2007 10:24 PM

Heap in nasm
 
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.

This is the basic theory.

wjevans_7d1@yahoo.co 06-24-2007 01:10 PM

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.

Hope this helps a little.

des_a 06-24-2007 11:17 PM

Good sugestion, though in my case, I'm still learning, so what it might be strange.


All times are GMT -5. The time now is 01:31 PM.