当经典 MacOS 进入程序时,68000 堆栈上有什么?

发布于 2024-08-30 12:15:19 字数 288 浏览 11 评论 0原文

我试图了解一个旧的经典 Mac 应用程序的入口点。我已经反汇编了第一个 CODE 资源(不是 CODE#0,它是跳转表)。该代码引用了堆栈外的一些变量:0004(A7)处的一个字,从000C(A7)开始的长字数组,其长度为0004(A7)处的值,以及超出该数组的最终长字似乎是一个指向字符串的指针。

长单词数组乍一看就像字符串,因此表面上看起来就像我们正在处理 (int argc, char ** argv) 情况,只不过“argv”数组是内联在堆栈帧中的。

当程序第一次被 Mac OS 调用时,它的堆栈/寄存器应该期待什么?

I'm trying to understand an old classic Mac application's entry point. I've disassembled the first CODE resource (not CODE#0, which is the jump table). The code refers to some variables off the stack: a word at 0004(A7), an array of long words of starting at 000C(A7) whose length is the value at 0004(A7), and a final long word beyond that array that seems to be a pointer to a character string.

The array of long words looks like strings at first glance, so it looks superficially like we're dealing with an (int argc, char ** argv) situation, except the "argv" array is inline in the stack frame.

What should a program be expecting on its stack / registers when it first gets called by the Mac OS?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简单爱 2024-09-06 12:15:19

我不知道它是否有任何用处(我只看这个问题,因为它的标题中有 68000...!)但是老Mac开发信息似乎在这里:

http://developer.apple.com/legacy/mac/library/documentation/macos8/mac8.html

(推测:argv 数据实际上很可能在堆栈上。将命令行分成几部分的一个明显方法是从末尾而不是开头开始。向后遍历命令行(使用 -(An) 寻址模式)并以这种方式查找片段,这可能会使事情变得有点复杂,但 68000 可以将立即值与内存进行比较,因此检查 \ 和 并不麻烦。类似(如果 Mac OS 这样做),一旦找到一个片段的开头,将其地址放入堆栈中 - 您可能已经方便地开始了(由于预先递减),但 PEA 会无论如何,让这一切变得简单——并在其末尾插入一个 0 来终止它。一旦所有指针都被推送,加载器可以执行MOVEA.L A7,-(A7)PEA A7来推送argv指针。

(如果你把它编码起来,这可能会很好地解决问题,所以如果这是实际采取的方法,我也不会感到惊讶。)

I don't know if it's any use (I only looked at this question because it had 68000 in the title...!) but ye olde Mac development information seems to be here:

http://developer.apple.com/legacy/mac/library/documentation/macos8/mac8.html

(Conjecture: the argv data may well actually be on the stack. An obvious way to split the command line into parts would be to start at the end rather than the beginning. Walk the command line backwards (using the -(An) addressing mode) and find the pieces that way. This potentially complicates things a little bit, but 68000 can compare immediate values to memory so it's no great hassle to check for \ and the like (if Mac OS does that). Once the start of a piece is found, put its address on the stack -- you've probably got the start handy (due to predecrement) but PEA would make this easy in any event -- and poke a 0 into its end to terminate it. Once all the pointers have been pushed, the loader could do MOVEA.L A7,-(A7) or PEA A7 to push the argv pointer.

(This would probably work out quite well if you coded it up and so it wouldn't surprise me if it was the approach actually taken.)

千纸鹤 2024-09-06 12:15:19

根据记忆,当您的 CODE 资源第一次被调用时,我认为堆栈上没有任何有趣的东西。经典 Mac OS 不使用 argc/argv。不过,已经很长时间了,所以我可能是错的,几年前我扔掉了所有旧的 Inside Mac 卷,所以我无法轻易检查。

From memory I don't think there is anything of interest on the stack when your CODE resource is first called. Classic Mac OS did not use argc/argv. It's been a long time though, so I could be wrong, and I threw out all my old Inside Mac volumes some years ago, so I can't easily check.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文