我有一个关于如何使用汇编语言检查软盘驱动器是否可用的问题。我检查了 RAM 内存是否足够,但我不知道如何检查软驱是否可用。我试过这个:CMP AH,0
JNE disk_error
,但是当我在检查 RAM 之后放这个时,什么也没有发生。当我输入continueToLoad :CMP AX,0
JNE fatal_disk_error
时,它工作正常,但加载栏后出现错误消息。Loader 我需要在加载栏之前显示该错误消息。 错误
main:
MOV DS,AX
PUSH CS
POP DS
MOV AH,0x00
MOV AL,0x03
INT 0x10
CALL ClearScreen
MOV BL,1010b
MOV BP,StrLoadKernel
MOV CX,length
MOV DH,13
MOV DL,30
CALL PrintString
MOV BL,1010b
MOV BP,StrReboot
MOV CX,length2
MOV DH,14
MOV DL,30
CALL PrintString
readKeys:
CALL PressKey
CMP AL,00011011b ; ESC binary code
JE Reboot
CMP AL,00001101b ; ENTER binary code
CALL ClearScreen
MOV BL,1010b
MOV BP,StrLoading
MOV CX,length4
MOV DH,14
MOV DL,35
CALL PrintString
JE LoadKernel
loop readKeys
jmp $
LoadKernel:
;CHECK IF RAM MEMORY > 64MB
MOV AH,0x88
INT 0x15
CLC
CMP AX,0xFA00
MOV BL,0011b
JNC printLoader
CALL ClearScreen
MOV BL,1100b
MOV BP,StrErrorRAM
MOV CX,length3
MOV DH,13
MOV DL,25
CALL PrintString
MOV BL,1100b
MOV BP,press_key
MOV CX,length6
MOV DH,14
MOV DL,25
CALL PrintString
CALL PressKey
CALL Reboot
JMP readKeys
JMP printLoader
changeToBlue:
MOV BL,1001b
JMP printLoader
changeToGreen:
MOV BL,1010b
JMP printLoader
changeToRed:
MOV BL,0100b
JMP printLoader
continueToLoad:
MOV AX,0
MOV DL,0
INT 0x13
;load kernel
MOV AX,kernel
MOV ES,AX
MOV BX,0
MOV AH,02h
MOV AL,01h
MOV CH,0h
MOV CL,02
MOV DH,0
MOV DL,0
INT 0x13
CMP AH, 0
jne fatal_disk_error
jmp kernel:0
RET
CALL printLoader
printLoader:
MOV BP,symbol ; stringul care dorim sa il afisam
MOV CX,symbolLength ; marimea stringului
MOV DH,16 ; randul (x)
MOV DL,[count] ; coloana (y)
CALL PrintString
INC DL
INC DL
INC DL
MOV [count],DL
CALL wait2sec
MOV AL,[pas]
INC AL
MOV [pas],AL
CMP AL,3
JE changeToBlue
CMP AL,6
JE changeToGreen
CMP AL,9
JE changeToRed
CMP AL,10
JE continueToLoad
loop printLoader
ClearScreen:
MOV AX,0600h
MOV CX,0000h
MOV BH,0Ah
MOV DX,1850h
int 0x10
RET
PressKey:
;read a key
MOV AH,0
INT 0x16
RET
PrintString:
MOV AH, 0x13
MOV AL,0
MOV BH,0
INT 0x10
; hide cursor
mov AH,0x01
MOV CX,2607h
INT 0x10
RET
Reboot:
db 0x0ea
dw 0x0000
dw 0xffff
RET
wait2sec:
MOV AH,0x86
MOV CX,0008h
MOV DX,6480h
int 0x15
RET
fatal_disk_error:
CALL ClearScreen
MOV AX,0
MOV ES,AX
MOV BL,1100b
MOV BP,disk_error
MOV CX,length5
MOV DH,16
MOV DL,30
call PrintString
CALL wait2sec
CALL PressKey
CMP AL,00011011b ; ESC binary code
jmp Reboot
RET
StrLoadKernel: db "Press ENTER to load the KERNEL "
length equ $-StrLoadKernel
StrReboot: db "Press ESC to restart "
length2 equ $-StrReboot
StrErrorRAM: db "Loading cancelled! ERROR : RAM < 64mb."
length3 equ $-StrErrorRAM
StrLoading: db "Loading... "
length4 equ $-StrLoading
disk_error: db "Floppy error! Press any key... "
length5 equ $-disk_error
press_key: db "Press any key to restart!"
length6 equ $-press_key
kernel equ 1000h
symbol: db 219
symbolLength equ $-symbol
count db 25
pas db 0
510-($-$$) db 0
DW 0xAA55