我写了一个读取硬盘主分区表的汇编程序.
但是int 13h执行后总是不成功.
下面是一部分代码(暂不考虑其他代码的原因)
%define PARTION_TABLE_OFFEST 0x1be
%define PARTION_TABLE_PER_SIZE 16
%define ACTIVE_PARTION_FALG 0x80
%define OS_LOAD_ADR_BASE 0x9000
%define OS_LOAD_ADR_OFFEST 0x100
...
;读取磁盘信息
.load_partions
;寻找分区
mov bp,BIOS_LOAD_MBR_ADR+PARTION_TABLE_OFFEST ;分区表的开始地址
mov cx,0 ;分区表的表项序号(0-4)
.search_active_partion
;寻找活动分区
cmp cx,4
je .no_active_partion
mov al,[bp]
cmp al,ACTIVE_PARTION_FALG
je .find_active_partion
add bp,PARTION_TABLE_PER_SIZE
inc cx
jmp .search_active_partion
.no_active_partion
mov bp,NoActivePartion
mov cx,34
call print_str
jmp $
.find_active_partion
;读取分区第一个扇区
inc bp
mov al,byte[bp]
mov byte[bp+0x0f],al;head
mov al,byte[bp+1]
and al,0x3f
mov byte[bp+0x10],al;sector
mov al,byte[bp+1]
shr al,6
mov byte[bp+0x11],al
mov al,byte[bp+2]
mov byte[bp+0x12],al;cyc
mov di,0
mov ah,0x00
mov dl,0x00
int 0x13
.read
cmp di,5
je .load_os_failed
mov ax,OS_LOAD_ADR_BASE
mov es,ax
mov ch,byte[bp+0x12]
mov dh,byte[bp+0x0f]
mov cl,byte[bp+0x10]
mov ah,0x02
mov al,1
mov bx,0
mov dl,0x80
int 0x13
jc .r
jmp .next
.r
inc di
mov ah,0x00
mov dl,0x00
int 0x13
jmp .read
.load_os_failed
.vga
mov al,0x13
mov ah,0x00
int 0x10
jmp $
.next
cmp byte[OS_LOAD_ADR_BASE],0
jne .vga
jmp $
...
用qemu调试得到ah错误码是01h:非法命令,为啥亚???