我自已先取一個主控制器的例子吧. 匯編如下
看前面幾段就可以了)
自已結束問題了.
; Program by bini.yi
.286c
DATA SEGMENT
msg1 db 'EIDE primary controller Serial number: $'
msg2 db 0AH,0DH,' Firmware revision: $'
msg3 db 0AH,0DH,' Model number: $'
msg4 db 0AH,0DH,' Cylinders: $'
msg5 db 0AH,0DH,' Heads: $'
conbcd dW 10000,1000,100,10,1
getdata1 db 512 dup(0)
DATA ENDS
STACK1 SEGMENT PARA STACK
DW 20 DUP(0)
STACK1 ENDS
CODE SEGMENT
ASSUME CS:CODE,DS
ATA,ES
ATA,SS:STACK1
START:
MOV AX,DATA
MOV DS,AX
MOV ES,AX
MOV DX,01F7H
MOV AL,0ECH
MOV DI,OFFSET getdata1
OUT DX,AL
CHK1: IN AL,DX
TEST AL,80H
JNZ CHK1
TEST AL,08H
JZ SNUM
MOV DX,01F0H
IN AX,DX
STOSW
MOV DX,01F7H
JMP CHK1
SNUM:
MOV CX,14H
PUSH CX
MOV CX,4H
PUSH CX
MOV DX,OFFSET msg1
MOV CX,0AH
MOV BX,27
LISTS:
MOV AH,09H
INT 21H
LEA DI,OFFSET getdata1
ADD DI,BX
LIS1:
MOV DL,[DI]
CMP DL,20H
JB OTHE
CMP DL,7EH
JNB OTHE
MOV AH,02
INT 21H
OTHE:
MOV DL,[DI-1]
CMP DL,20H
JB LOX
CMP DL,7EH
JNB LOX
MOV AH,02
INT 21H
LOX:
INC DI
INC DI
LOOP LIS1
FIRMN:
POP CX
CMP CL,04H
JNE MODELN
MOV DX,OFFSET msg2
MOV BX,2FH
JMP LISTS
MODELN:
CMP CX,14H
JNE CYHEN
MOV DX,OFFSET msg3
MOV BX,37H
JMP LISTS
CYHEN:
MOV AH,09H
MOV DX,OFFSET msg4
INT 21H
LEA DI,OFFSET getdata1
ADD DI,06H
MOV AX,[DI]
PUSH AX
MOV CX,02H
PUSH CX
SUB DI,04H
MOV AX,[DI]
MOV CX,5
MOV DH,0
CONV:
MOV BL,0
LEA SI,OFFSET conbcd
CONVS:
SUB AX,[SI]
JC NEXT
INC BL
JMP CONVS
NEXT:
ADD AX,[SI]
PUSH AX
INC SI
INC SI
CMP BL,0
JE CHECK
MOV DH,1
JMP NEXT2
NEXT1:
ADD BL,20H
JMP ENDCHK
NEXT2:
ADD BL,30H
ENDCHK:
MOV AH,02H
MOV DL,BL
INT 21H
POP AX
MOV BL,0
LOOP CONVS
POP CX
CMP CL,02H
JE HEADS
JMP EXIT1
HEADS:
LEA DX,OFFSET msg5
MOV AH,09H
INT 21H
POP AX
MOV CX,5
JMP CONV
CHECK:
CMP DH,0
JE NEXT1
JMP NEXT2
EXIT1:
MOV AH,4CH
INT 21H
CODE ENDS
END START