OUT &H1F6, &HA0
OUT &h1F2,1
OUT &H1F3, 1
OUT &h1F4,1
OUT &h1F5,1
OUT &H1F7, &HEC '获得硬盘信息的命令
DO WHILE flag <> &H58
f lag = INP(&H1F7)
if inkey$=chr$(27) then '如果按ESC键,终止程序
print "无法获得硬盘序列号"
end
end if
LOOP
re$ = SPACE$(18)
FOR i% = 1 TO 18
READ a$
H$ = CHR$(VAL("&H" + a$))
MID$(re$, i%, 1) = H$
NEXT i%
duan% = varSEG(re$):offe% = SADD(re$)
DEF SEG = duan%
print "本硬盘的序列号为 ";
FOR i = 1 TO 16
CALL Absolute(r%, offe%) '调用在qb中的内嵌汇编机器码
r1% = r% AND &HFF
r2% = (r% AND &HFF00) / &H100
IF i > 9 AND i < 15THEN PRINT CHR$(r1%); CHR$(r2%);
NEXT i
DEF SEG
END
'此DATA中的数据为机器码,用于读端口字数据(qb中的端口语句只能按字节读写端口,不能按字读写)
DATA 55,89,e5,ba,f0,01,ed,86,e0,8b,5e,06,89,07,5d,ca,02 ,00
'55 push bp
'89E5 mov bp, sp
'BAF001 mov DX, 01F0h
'ED in ax, dx
'86E0 xchg ah, al
'8B5E06 mov bx, [bp+06]
'8907 mov [BX], AX
'5D pop BP
'CA0200 ret 2