English 中文(简体)
参考数
原标题:LIFO stack algorithm design

I m 执行一个以身为单位的低价竞标,I ve试图在解释或概述处理主食的算法的文献上阅读。 例如:

int i = 3
int j = 4
int k = 5

让我们选择<代码>i,j,和k为当地变量,因此这些变量传统上将储存在 st上。 编组/条码翻译将研究如下内容:

pushi 3
pushi 4
pushi 5

标题是:<代码>5 4 3。

我有笔记和笔记,因此有<代码>pushi/code>。 然而,我的问题是,在座标上(有的<编码>ptr*或字面识别),编辑或口译将如何知道,如果我想做像int x = i j,在定义之后,我必须填写2<>/strong>和,分别为。 我最好不要失去<代码>k。 (除非登记在册或某处,然后将其推回)?

我希望我的问题具有某种意义,而且也许会采取更加划时代的办法: 感谢你们的见解!

最佳回答

通常用一个叫做tackframe。 您一度为all本地变量(分配/开发成登记册的变数)分配空间,储存该块的基址,并在该区被抵消后运作。 接着,在范围撤出的 st脚石中, everything掉一切。

问题回答

汇编者这样做的是,通过直接添加ack点,然后在不使用推力和用正常记忆读功能的情况下,将 index升为平价。 之后,在完成后将 st回原价值。





相关问题
How to add/merge several Big O s into one

If I have an algorithm which is comprised of (let s say) three sub-algorithms, all with different O() characteristics, e.g.: algorithm A: O(n) algorithm B: O(log(n)) algorithm C: O(n log(n)) How do ...

Grokking Timsort

There s a (relatively) new sort on the block called Timsort. It s been used as Python s list.sort, and is now going to be the new Array.sort in Java 7. There s some documentation and a tiny Wikipedia ...

Manually implementing high performance algorithms in .NET

As a learning experience I recently tried implementing Quicksort with 3 way partitioning in C#. Apart from needing to add an extra range check on the left/right variables before the recursive call, ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Enumerating All Minimal Directed Cycles Of A Directed Graph

I have a directed graph and my problem is to enumerate all the minimal (cycles that cannot be constructed as the union of other cycles) directed cycles of this graph. This is different from what the ...

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...