int 13h ah=08h ,我做错了什么?

发布于 2024-12-28 11:49:24 字数 895 浏览 2 评论 0原文

好的,这是我的代码..

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


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

在屏幕上打印 ascii 字符

int 10h启动后 结果始终是“笑脸 ascii 字符”,包括 80h、81h、82h 等。 输出屏幕在这里 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

okay, so this is my code..

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 prints the ascii character on screen

after booting
the result is always the "smiley ascii character" for everything including 80h,81h,82h..
output screen is here http://postimage.org/image/5twm1ml5j/
it's null for ah=0

i've attached harddrives, usbs to my laptop before trying out...

What am i doing Wrong??

using qemu pc emulator and nasm

This is my entire code.

    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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倾听心声的旋律 2025-01-04 11:49:24

为什么你把 int 称为 13h ?这是针对磁盘服务的,特别是当 ah=08h 时,您需要第一个驱动器的参数! (请查看此处)。
然后你将 ah 中的任何内容(肯定是这些之一)移动到 al 中,这是要打印的字符。打印的面孔是 ascii 字符编号 1,因此,再次查看 此处,您给出了错误的参数13小时内。 ;)

Why are you calling the int 13h? That's for disk services, in particular with ah=08h you're asking for the first drive's parameters! (check here).
Then you're moving whatever is in ah (one of these for sure) into al, which is the character to print. The face printed is ascii char number 1 so, looking here again, you gave wrong parameters to int 13h. ;)

沫尐诺 2025-01-04 11:49:24

首先,始终使用“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 扩展” - 具体来说,“int 0x13, ah=0x48”(请参阅​​ http://www.ctyme.com/intr/rb-0715.htm)。

First, always start a boot loader with a "jmp" (required by some ancient Compaq systems instead of the "boot signature"), disable IRQs when you load SS and SP (in case CPU is 8086), never write addresses and segments in decimal (use hexadecimal), the BIOS tells you the device number in DL (don't "hard code" your own), and you shouldn't let the CPU execute data/trash (put a "jmp $" or something after the "int 0x10").

Next, the "smiley ASCII character" isn't an ASCII character. For the "code page 437" character set (what you're probably seeing) there's 2 different smiley characters - a smiley outline (character 0x01) and a solid smiley (character 0x02). These would correspond to error codes "0x01 = invalid function in AH or invalid parameter" or "0x02 = address mark not found". The first error is far more likely.

An "invalid function in AH or invalid parameter" error could be caused by having the wrong value in DL (e.g. wrong device number). Alternatively, the device number might be correct but the function might not be supported for that device. Due to disk size problems the old "int 0x13" functions aren't really used for hard drives anymore (they're limited to 1024 cylinders, 256 heads and 63 sectors, or about 7.875 GiB or 8.455 GB, and modern hard disks are much larger). For hard drives you should try the "int 0x13 extensions" instead - specifically, "int 0x13, ah=0x48" (see http://www.ctyme.com/intr/rb-0715.htm ).

浪推晚风 2025-01-04 11:49:24
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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文