【问题标题】:NASM Boot Loader strange behaviorNASM 引导加载程序奇怪的行为
【发布时间】:2011-12-08 21:04:51
【问题描述】:

我正在尝试编写一个引导加载程序,但我的实验都没有奏效,直到我发现了这个问题:Why doesn't this boot loader code work?

我已经简化了这个程序,只在屏幕上写入一个字符。

[ORG 0x7C00]
[BITS 16]

realstart:
    jmp start
    nop


start:
    xor ax,ax
    mov ds,ax
    mov es,ax
    xor bx,bx
    mov ah, 0x0e
print:
    mov al, "A"
    int 0x10
end:    
    cli
    hlt  

    times 510 - ($-$$) db 0
    dw 0xAA55

它编译得很好,但是在objdump 中没有任何 int 0x10 命令。

如果我留下字符串 (this file),一切正常。

问题在哪里?

(在 Cygwin Win7 SP1 上使用 NASM 2.08.02-1 编译)

【问题讨论】:

  • 我正在编译:nasm -O0 -f bin bootLoader.asm -o bootLoader.bin
  • 发布 objdump 转储。用 FASM 编译并用 ndisasm 转储,int 10h 就在那里。
  • 我已经上传了屏幕截图:s2.photobucket.com/albums/y31/bannyy/NASM%20problem我正在使用 Win7 SP1、Cygwin、NASM。
  • 我无法重现这种行为,因为 55 AA 放置不正确,似乎有很多事情出错了。你能用给出错误输出的文件来更新你的问题吗?
  • 好像一点都不对,你用的是最新版吗?

标签: assembly nasm bootloader


【解决方案1】:

代码似乎没有任何问题。如果使用 ndisasm 反汇编代码会产生缺少 int 0x10 的结果,那将是非常奇怪的。所以我猜你谈论的是在运行时转储代码。引导扇区通常在跳转指令之后包含一个引导记录(它告诉引导加载程序有关媒体的大小等)。也许 BIOS 出于某种原因干预了它认为是引导记录的内容?

【讨论】:

    【解决方案2】:
    Bits 16
    org 0x7c00
    start:
    xor ax,ax
    mov ah,0x0E
    mov al,'A'
    int 10h
    mov al,10h
    int 16h
    int 19h
    hlt
    times 510-($-$$) db 0
    dw 0xAA55
    

    试试这个代码。如果它不起作用,请告诉我。

    【讨论】:

      猜你喜欢
      • 2012-03-28
      • 1970-01-01
      • 2022-01-07
      • 2013-07-07
      • 1970-01-01
      • 2012-04-14
      • 1970-01-01
      • 2021-03-30
      相关资源
      最近更新 更多