【问题标题】:int 13h ah=08h , What am i doing wrong?int 13h ah=08h ,我做错了什么?
【发布时间】:2012-02-17 20:09:49
【问题描述】:

好的,这是我的代码..

mov ah,08h
mov dl,80h ;have Tried for 81h,82h....
int 13h


mov ah,0Eh
    int 10h ;  printing the value in al.

int 10h 在屏幕上打印 ascii 字符

开机后 结果始终是包括 80h、81h、82h 在内的所有内容的“笑脸 ascii 字符”。 输出屏幕在这里http://postimage.org/image/5twm1ml5j/ ah=0 为空

在尝试之前,我已将硬盘、USB 连接到我的笔记本电脑...

我做错了什么??

使用 qemu pc 模拟器和 nasm

这是我的全部代码。

    BITS 16

start:
mov ax, 1984    ; Set up 4K stack space after this bootloader
add ax, 288     ; (4096 + 512) / 16 bytes per paragraph
mov ss, ax
mov sp, 4096

mov ax, 1984        ; Set data segment to where we're loaded
mov ds, ax




mov ah,08h
mov dl,80h
int 13h


mov ah,0Eh
int 10h








times 510-($-$$) db 0   ; Pad remainder of boot sector with 0s
dw 0xAA55       ; The standard PC boot signature

【问题讨论】:

标签: assembly operating-system nasm bootloader x86-16


【解决方案1】:

你为什么叫 int 13h?那是针对磁盘服务的,尤其是在 ah=08h 时,您要询问第一个驱动器的参数! (检查here)。
然后你将 ah 中的任何内容(肯定是 these 之一)移动到 al 中,这是要打印的字符。打印的面是 ascii char number 1 所以,再看here,你给 int 13h 提供了错误的参数。 ;)

【讨论】:

  • 我想要驱动器的参数!..磁头轨道和扇区....知道为什么我总是得到01作为我的回报吗?给我正确的参数?
  • @TejeshWayne:ah 总是包含 01h 而 al 包含状态。其他寄存器包含您正在寻找的信息(查看我的第一个链接)
  • 我的错误对不起!.. 现在明白了 :) 不过谢谢 BlackBear.. 当我在 al.. 中打印值时,我得到了这个 postimage.org/image/fg69cd0wn,我猜它是 ascii 代码 192.. 任何知道为什么?
  • 为所有驱动器 80h,81,82 获取相同的 ascii 代码...我的代码.. mov ah,08h mov dl,80h int 13h mov ah,0Eh int 10h
  • @TejeshWayne:检查进位标志。如果设置了那就有问题了
【解决方案2】:

首先,始终使用“jmp”启动引导加载程序(一些古老的 Compaq 系统需要,而不是“引导签名”),在加载 SS 和 SP 时禁用 IRQ(如果 CPU 为 8086),切勿写入地址和十进制段(使用十六进制),BIOS 告诉你 DL 中的设备号(不要“硬编码”你自己的),你不应该让 CPU 执行数据/垃圾(放一个“jmp $”或“int 0x10”之后的东西)。

接下来,“笑脸 ASCII 字符”不是 ASCII 字符。对于“代码页 437”字符集(您可能会看到),有​​ 2 个不同的笑脸字符 - 笑脸轮廓(字符 0x01)和实心笑脸(字符 0x02)。这些将对应于错误代码“0x01 = AH 中的无效功能或无效参数”或“0x02 = 未找到地址标记”。第一个错误的可能性更大。

“AH 中的函数无效或参数无效”错误可能是由于 DL 中的值错误(例如错误的设备号)引起的。或者,设备编号可能正确,但该设备可能不支持该功能。由于磁盘大小问题,旧的“int 0x13”函数不再真正用于硬盘驱动器(它们被限制为 1024 个柱面、256 个磁头和 63 个扇区,或大约 7.875 GiB 或 8.455 GB,而现代硬盘很多更大)。对于硬盘驱动器,您应该尝试“int 0x13 extensions” - 具体而言,“int 0x13, ah=0x48”(请参阅​​http://www.ctyme.com/intr/rb-0715.htm)。

【讨论】:

  • @Brendan 感谢您的回复:),我尝试使用 int 13h & ah=48h,当我打印 al 寄存器时,它是 ascii 代码 192 或 C0h .. 没有给出错误代码可悲.. :-/ 这里是 postimage.org/image/fg69cd0wn .. 我的代码在这里 pastebin.com/M7JTfDHC
  • @Tejesh:BIOS 在 AH 中返回状态,但您显示的是 AL。无论如何,这是我一起拍的东西:pastebin.com/BEnjfwBs
【解决方案3】:
INT 13h AH=08h: Read Drive Parameters
Parameters:

Registers
AH  08h = function number for read_drive_parameters
DL  drive index (e.g. 1st HDD = 80h)
ES:DI[4]    set to 0000h:0000h to work around some buggy BIOS

Results:

CF  Set On Error, Clear If No Error
AH  Return Code
DL  number of hard disk drives
DH[4]   logical last index of heads = number_of - 1 (because index starts with 0)
CX  [7:6] [15:8][4] logical last index of cylinders = number_of - 1 (because index starts with 0)
[5:0][4] logical last index of sectors per track = number_of (because index starts with 1)

BL[4]   drive type (only AT/PS2 floppies)
ES:DI[4]    pointer to drive parameter table (only for floppies)

http://en.wikipedia.org/wiki/INT_13H

【讨论】:

    猜你喜欢
    • 2014-09-16
    • 2011-04-08
    • 2011-09-09
    • 2012-01-31
    • 1970-01-01
    • 2011-06-01
    • 1970-01-01
    • 2021-04-14
    相关资源
    最近更新 更多