assembly - 如何确定启动设备

标签 assembly x86 device boot

我又遇到了一个不太容易用谷歌搜索的问题。让我们假设 BIOS 已经从指定设备加载了我的引导加载程序,我现在如何找出它是哪个设备,以便我可以将我的操作系统的其余部分加载到 ram 中?

最佳答案

如果是MBR bootstrap (也可能是其他情况?我不是 100% 确定)DL 将包含 驱动器号,即你可以做这样的事情(替换你自己的内存布局等):

EntryPoint: 
    xor ax, ax
    mov ss, ax
    mov ds, ax
    mov sp, 0x7c00
.DiskReset:
    mov ah, 0
    int 0x13
    jc .DiskReset
    mov ax, 0x50 ; load to 0x500 linear address. It has unused space up to 0x7bff
    mov es, ax
    xor bx, bx
    mov ax, 0x023B ; count = 0x3b = 59, the maximum..
    mov cx, 0x0002
    xor dh, dh ; leave (dl = drive number) intact
    int 0x13
    jnc .ReadDone
    mov si, ReadError
    call PrintString16
    jmp .DiskReset
.ReadDone:
    ; ......

关于assembly - 如何确定启动设备,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6787819/

相关文章:

android - 自定义Android开发环境分辨率(Android x86与eclipse结合)

assembly - 如何为我的 Bootstrap 制作内核?

linux - Banana Pi 未启动(红色 LED 亮起)

assembly - 如何在 16 位汇编中执行另一个文件

assembly - 在 Art of Exploitation 示例中被 [ebp-0xc] 而不是 [ebp-4] 混淆

windows - 试图找出 MASM 语法

android - 处于测试模式的设备 Admob

ios - 从 ios 设备连接到 localhost

assembly - 转置 SSE2/SSSE3 上的 8 个 16 位元素寄存器

algorithm - 在SSE/AVX中选择唯一/重复数据删除