NASM - 从 USB 驱动器加载代码
任何汇编专家都知道表示第一个 USB 驱动器的参数(寄存器dl)吗?
我正在学习一些 NASM 教程,并且希望获得一个物理启动(我可以使用 qemu 获得一个干净的启动)。
这是从磁盘加载“内核”数据的代码部分:
loadkernel:
mov si, LMSG ;; 'Loading kernel',13,10,0
call prints ;; ex puts()
mov dl, 0x00 ;; The disk to load from
mov ah, 0x02 ;; Read operation
mov al, 0x01 ;; Sectors to read
mov ch, 0x00 ;; Track
mov cl, 0x02 ;; Sector
mov dh, 0x00 ;; Head
mov bx, 0x2000 ;; Buffer end
mov es, bx
mov bx, 0x0000 ;; Buffer start
int 0x13
jc loadkernel
mov ax, 0x2000
mov ds, ax
jmp 0x2000:0x00
如果有什么区别的话,我正在运行普通的 Dell Inspiron 15 BIOS。
显然,对我来说正确的值是 0x80。
BIOS 加载硬盘驱动器并从 0x80 开始标记它们 根据这个答案。
由于某种原因,我的特定 BIOS 决定将 USB 驱动器作为第一个加载,这样我就可以从那里启动。
Would any assembly gurus know the argument (register dl) that signifies the first USB drive?
I'm working through a couple of NASM tutorials, and would like to get a physical boot (I can get a clean one with qemu).
This is the section of code that loads the "kernel" data from disk:
loadkernel:
mov si, LMSG ;; 'Loading kernel',13,10,0
call prints ;; ex puts()
mov dl, 0x00 ;; The disk to load from
mov ah, 0x02 ;; Read operation
mov al, 0x01 ;; Sectors to read
mov ch, 0x00 ;; Track
mov cl, 0x02 ;; Sector
mov dh, 0x00 ;; Head
mov bx, 0x2000 ;; Buffer end
mov es, bx
mov bx, 0x0000 ;; Buffer start
int 0x13
jc loadkernel
mov ax, 0x2000
mov ds, ax
jmp 0x2000:0x00
If it makes any difference, I'm running a stock Dell Inspiron 15 BIOS.
Apparently, the correct value for me is 0x80.
The BIOS loads the hard drives and labels them starting at 0x80 according to this answer.
My particular BIOS decides to load the USB drive up as the first, for some reason, so I can boot from there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
简单的答案是
dl
的正确值位于dl
中。令人高兴的答案是
dl
值与int 13h, ah=8
GET DRIVE PARAMETERS 返回要使用的几何图形,并允许 FAT12 软盘映像代码从任何 BIOS 运行/ 可以从 USB 闪存驱动器启动的版本。请参阅我的帖子:USB 启动秘密
The simple answer is that the correct value for
dl
is indl
.The happy answer is that the
dl
value withint 13h, ah=8
GET DRIVE PARAMETERS returns the geometry to use and allows the FAT12 floppy disk image code to run from any BIOS/version that can boot from a USB flash drive.See my post here: USB Booting Secrets