简单的NASM"启动程序"无法正确访问内存?

Ano*_*ohn 5 assembly memory-management nasm bootloader

**请注意,当我说启动程序时,我并不是指启动操作系统的程序.我的意思是,一个简单的程序,当你启动计算机并执行某些操作时运行.

好吧,所以我不是非常精通Assembly/NASM,但我认为我已经掌握了很好的编写简单启动程序.

好吧,我以为我有足够的把握.显然不是.

我尝试了一个在网上找到的简单启动程序.它运行良好(打印字母'A').然后我修改它以打印存储在内存中的字母.它失败了; 而不是打印'A',它打印出一个笑脸.(我发誓,电脑现在正嘲笑我.)

这是源文件中的代码:

[BITS 16]    ; We start up in 16-bit real mode
[ORG 0x7C00] ; We're booted into memory at this address. (Or so I'm told)

mov ah, 0x0E       ; Teletype command
mov bh, 0x00       ; Page number
mov bl, 0x07       ; Attributes (7 == white foreground, black background)
mov al, [testChar] ; Character to print; load it from the memory referenced by testChar.

int 0x10  ; Tell the BIOS to execute the teletype command.

jmp $  ; Infinite loop prevents us from going off and executing the other junk in memory

testChar db 65  ; This is the character we want to print. 'A'.

; The following code pads the rest of the outputted binary file
;   and concludes it with the bootloader signature so I don't have
;   to do so manually.
times 510-($-$$) db 0
dw 0xAA55
Run Code Online (Sandbox Code Playgroud)

如果我用' move al,65 ' 替换' move al,[testChar] ',则正确打印字母'A'.我试过移动内存声明,我已经尝试了BITS和ORG周围的括号或没有括号的每个组合,我尝试递增和递减testChar(即[testChar + 1]).每次打印时都会显示一个笑脸,一个反向笑脸(当我增加testChar时),或者什么都没有(当我在代码之前放入内存声明时,可能是因为没有执行代码= P).我无法得到该死的东西.

现在,对于规范(因为它们可能相关):

  • 我正在使用英特尔奔腾II处理器运行戴尔Latitude CPi,因为这是我必须测试的所有内容(我没有使用普通计算机测试汇编程序.没有.).我很确定说处理器是x86,因为我在它上面运行Windows XP,Ubuntu和Arch Linux.

  • 我目前正在使用NASM在Arch Linux上编写和编译程序.

  • 引导程序从软盘运行

  • 我使用' nasm -f bin FILENAME '来编译代码.

  • 然后我使用'mtools'包中的'mformat'命令为AL通过' mformat -f 1440 -B BOOTPROGRAM A: ' 将编译的引导程序传送到软盘.

那么,这次搞砸了什么?或者我的处理器/ BIOS有问题吗?