86 NASM'组织'指导意义 [英] x86 NASM 'org' directive meaning

查看:174
本文介绍了86 NASM'组织'指导意义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下面这个教程作为首次进军引导程序/ OS开发利用NASM 86:

I am following this tutorial as a first foray into bootloader/OS development for x86 using NASM:

<一个href=\"http://joelgompert.com/OS/TableOfContents.htm\">http://joelgompert.com/OS/TableOfContents.htm

和我在第4课,这使我的引导程序打印你好,世界字符串。
我不理解组织指令的含义(指令?)。

And I'm on Lesson 4, which is making my bootloader print the "Hello, world" string. I'm not understanding the meaning of the org instruction (directive?).

据我了解,组织定义了正在执行的程序被加载到内存中。这是通过使用任何种类的程序中的标签或相对地址的在需要时

As I understand it, org defines where the program being executed is loaded into memory. This is needed when using any sort of labels or relative addresses in the program.

假如我有在我的计划是这样的标签定义的字符串:

Suppose I have a string defined with a label like this in my program:

szHello db 'Hello, world!', 0

和我再后来试图引用这个标签像这样的(只有相关的片段):

And I then later try to reference that label like this (only relevant snippets):

org 0x7c00
xor ax, ax
mov ds, 0
...
mov si, szHello
lodsb
...
int 0x10 ; Print first character of szHello

我的问题是,这是为什么不等同于这个?

My question is, why is that not equivalent to this? :

org 0
mov ds, 0x7c00
...
mov si, szHello
lodsb
...
int 0x10

当我运行的第一个例子,我的字符串正确显示。第二个例子是行不通的。

When I run the first example, my string appears correctly. The second example does not work.

指针相关的文件也将是极大的AP preciated,如果这个问题是在我的部分概念问题。

Pointers to relevant documentation would also be greatly appreciated, if the issue is a conceptual problem on my part.

推荐答案

0000:7C00不等同于7C00:0000。段部段,而不是字节计数。试试这个:

0000:7C00 is not equivalent to 7C00:0000. The segment part is counted in paragraphs, not bytes. Try this instead:

mov ds, 0x7c0

这篇关于86 NASM'组织'指导意义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆