世界您好引导程序不工作 [英] Hello World bootloader not working

查看:133
本文介绍了世界您好引导程序不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在努力通过教程 href=\"http://viralpatel.net/taj/tutorial/hello_world_bootloader.php\" rel=\"nofollow\">显示的Hello World。

I've been working through the tutorials on this webpage which progressively creates a bootloader that displays Hello World.

第二教程(在这里我们试图得到一个A是输出)的作品完美,但第一教程并没有为我工作了! (BIOS将完全忽略软盘和靴子直接进入Windows)。这是不成问题的,但任何解释将AP preciated。

The 2nd tutorial (where we attempt to get an "A" to be output) works perfectly, and yet the 1st tutorial doesn't work for me at all! (The BIOS completely ignores the floppy disk and boots straight into Windows). This is less of an issue, although any explanations would be appreciated.

真正的问题是,我无法取得第三个教程。相反,在输出的Hello World,我得到在屏幕的左下角一个不寻常的字符(和闪烁的光标)。它看起来有点像一个圆角矩形内的笑脸。有谁知道怎么弄的Hello World显示,因为它应该?

The real problem is that I can't get the 3rd tutorial to work. Instead on outputting "Hello World", I get an unusual character (and blinking cursor) in the bottom-left corner of the screen. It looks a bit like a smiley face inside a rounded rectangle. Does anyone know how to get Hello World to display as it should?

推荐答案


你说开机直接进入窗口,所以我假设你使用的是物理PC。未来记作:始终使用仿真器的发展!这只是简单。我喜欢Bochs的为OSDeving导致它有很好的调试功能。现在,到了可能的解决方案。

You say "boot straight into windows" so I assume you are using a physical PC. Future note to make: Always use an emulator for development! It's just easier. I like Bochs for OSDeving cause it has nice debugging features. Now, onto the possible solution.

有很多是打破了IBM PC的非正式规格为0x7C00加载地址越野车的BIOS的。

There are a lot of buggy BIOSes that break the informal specifications of the IBM PC for the 0x7C00 load address.

这可以给大量的内存地址,这样每当你组装的问题。所以要一开始是这样的:

This can give a lot of problems with memory addresses and such whenever you are assembling. So make the beginning look like this:

[BITS 16] ;tell the assembler that its a 16 bit code
[ORG 0x7C00] ;this tells the assembler where the code will be loaded at when it runs on your machine. It uses this to compute the absolute addresses of labels and such.

jmp word 0:flush ;#FAR jump so that you set CS to 0. (the first argument is what segment to jump to. The argument(after the `:`) is what offset to jump to)
;# Without the far jmp, CS could be `0x7C0` or something similar, which will means that where the assembler thinks the code is loaded and where your computer loaded the code is different. Which in turn messes up the absolute addresses of labels.
flush: ;#We go to here, but we do it ABSOLUTE. So with this, we can reset the segment and offset of where our code is loaded.
mov BP,0 ;#use BP as a temp register
mov DS,BP ;#can not assign segment registers a literal number. You have to assign to a register first.
mov ES,BP ;#do the same here too
;#without setting DS and ES, they could have been loaded with the old 0x7C0, which would mess up absolute address calculations for data. 

请参阅在一些负载0x07C0:0000 和大多数负载(其认为恰当的)在 0×0000:7C00 。这是相同的平面地址,但不同网段的设置能真正搞砸了绝对的内存地址。因此,让我们删除汇编神奇,看看它是什么样子(注意,我不保证地址与此完全正确的。我不知道所有的运算codeS的大小)

See, some load at 0x07C0:0000 and most load(and its considered proper to) at 0x0000:7C00. It is the same flat address, but the different segment settings can really screw up absolute memory addresses. So let's remove the "magic" of the assembler and see what it looks like (note I don't guarantee addresses to be completely correct with this. I don't know the size of all opcodes)

jmp word 0:0x7C04 ;# 0x7C04 is the address of the `flush` label 
...

所以,我们跳转到一个绝对地址。

So, we jump to an absolute address.

现在然后。当我们不这样做,会发生什么?

Now then. What happens when we don't do this?

采取这种方案,例如:

mov ax,[mydata]
hlt

mydata: dw 500 ;#just some data

这拆解喜欢的东西。

mov ax,[0x7C06] 

哦,它使用绝对地址,所以怎么可能出问题?那么,如果DS实际上是 0x7C0 ?那么不但得不到预期的汇编 0:0x7C06 它会得到 0x7C0:0x7C06 这是不会同一平面地址。

Oh, well it uses absolute addressing, so how could that go wrong? Well, what if DS is actually 0x7C0 ? then instead of getting the assembler expected 0:0x7C06 it will get 0x7C0:0x7C06 which are not the same flat address.

我希望这有助于你理解。这的确是一个复杂的话题,但并需要一段时间底层编程的充分了解。

I hope this helps you to understand. It's really a complicated topic though and takes a while of low level programming to fully understand.

这篇关于世界您好引导程序不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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