;该文件封装了LBA28读取一个扇区的汇编过程
%ifndef _LBA28_
%define _LBA28_
;参数说明:eax为起始扇区号,ds:ebx为缓冲区地址
read_one_sector:
push eax
push ebx
push ecx
push edx
push esi
mov esi,eax
mov al,1
mov dx,0x1f2 ;向端口0x1f2写入读取的扇区数
out dx,al
mov eax,esi
inc dx
out dx,al ;向端口0x1f3写入起始扇区号0-7位
inc dx
shr eax,8
out dx,al ;向端口0x1f4写入起始扇区号8-15位
inc dx
shr eax,8
out dx,al ;向端口0x1f5写入起始扇区号16-23位
inc dx
shr eax,8
or al,0xe0
out dx,al ;向端口0x1f6写入起始扇区号24-31位
inc dx
mov al,0x20
out dx,al ;向端口0x1f7写入磁盘读取命令0x20
.waits:
in al,dx
and al,0x88
cmp al,0x08
jne .waits
mov cx,256
mov dx,0x1f0
.read_word:
in ax,dx ;循环读取512字节
mov [ebx],ax
add ebx,2
loop .read_word
pop esi
pop edx
pop ecx
pop ebx
pop eax
ret
%endif