开发者

How do I implement a datatype, like a stack, in assembly?

I need to implement a custom data structure in assembly. Preferably, it needs to be dynamic. Something like a linked list in C++/Java where each element points to the next element. 开发者_开发知识库Please note that the size of each element may vary.

How can I do this?


The same you would in C. Assembly has functions and address spaces. Start with the basics: what functions does your stack need to have? Put the actual datastructures aside and focus on the big picture.

All you need is a function to push() and a function to pop(), a place to stick these items in the memory, and a counter to tell you how much of that space you've used up.

Oh, you should probably review your data structures before starting, as in neither C++ nor Java (or any other language, as a matter of fact) does an object pushed onto a stack point to the next object on the stack. That's called a linked list.


Try implementing your data structure using C and then look at the assembly generated. For your memory needs, however, it might require some more careful considerations (such as using non-volatile vs. volatile memory for storage for the varying sized elements).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜