组装编译器如何知道在哪里放置功能?

发布于 2025-02-08 07:20:16 字数 382 浏览 1 评论 0原文

组装编译器如何知道在哪里放置标签/功能?
我一直在考虑这个问题,但找不到答案。

示例代码:

Func1:
    mov %ax, 0x100

jmp Func1

如何知道将其放置在.bin/.o文件中的位置?
否则它只是跳到功能的结尾。
我尝试创建自己的操作代码只是为了使我的模拟器跳过功能。但是,当需要称呼它时,它会以偏移 + 1的形式跳到它来跳过功能操作代码。 \

要清楚,我正在制作自己的仿真器和编译器,以了解更多处理器的工作方式。我可以创建简单的编译器,但是在某个时候,我必须添加跳跃,有条件的跳跃和比较。

我在Python中创建模拟器。

如果有人知道答案,请回答。我为我的英语不好而道歉。

How do assembly compilators know where to place labels/functions?
I have been thinking about this problem and I couldn't find the answer.

Example code:

Func1:
    mov %ax, 0x100

jmp Func1

How does it know where to place it in good position in .bin/.o file?
Or it just jumps to end of the Function.
I tried to create my own operation code just to make my emulator skip the function. But when it needs to be called it gets jumped to it with offset + 1 to skip the function operation code. \

To be clear, I'm making my own emulator and compilator to understand more how processors work. I can create simple compilators but at some point I must add jumps, conditional jumps and comparisons.

I create my emulator in python.

If anyone knows answer please answer. And I apologise for my bad english.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文