LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-22-2007, 10:24 PM   #1
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,409
Blog Entries: 43

Rep: Reputation: 35
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.
 
Old 06-24-2007, 01:10 PM   #2
wjevans_7d1@yahoo.co
Member
 
Registered: Jun 2006
Location: Mariposa
Distribution: Slackware 9.1
Posts: 938

Rep: Reputation: 31
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.
 
Old 06-24-2007, 11:17 PM   #3
des_a
Senior Member
 
Registered: Sep 2006
Posts: 1,409

Original Poster
Blog Entries: 43

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
heap or stack yashwantpinge Programming 1 03-17-2006 07:25 AM
Is array allocated on heap set to zero? nibbler Programming 3 12-14-2005 02:55 AM
increasing heap size podollb Linux - Software 3 03-06-2005 11:42 PM
dumping and browsing heap with gdb Hano Programming 0 07-15-2004 10:55 PM
Modifying the heap available to a process exitsfunnel Linux - Software 0 12-10-2003 09:20 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration