Saturday, September 25, 2010

Compilation of various source - DEV


name dev
page 60,132
title''DEV --- Report installed device drivers''

; DEV --- a utility to report device header information for
; All installed device drivers
;
; Requires PC-DOS or MS-DOS 2.0.
;
; Used in the form:
; A> DEV
;
; Version 1.0 December 12, 1984
; Copyright (c) 1984 by Ray Duncan

cr equ 0dh; ASCII carriage return
lf equ 0ah; ASCII line feed
blank equ 20h; ASCII space code
eom equ''$''; end of string marker


cseg segment para public''CODE''

assume cs: cseg, ds: data, es: data, ss: stack


dev proc far; entry point from PC-DOS

push ds; save DS: 0000 for final
xor ax, ax; return to PC-DOS
push ax
mov ax, data; make our data segment
mov ds, ax; addressable via DS and ES.
mov es, ax
mov ah, 30h; check version of PC-DOS.
int 21h
cmp al, 2
jae dev1; proceed, DOS 2.0 or greater.
mov dx, offset msg2; DOS 1.x --- print error message.
jmp dev6

dev1: mov cx, ax; save DOS version number.
mov ah, 15; now try and open the "NUL" device.
mov dx, offset nulfcb
int 21h
or al, al; opened successfully?
jz dev2; yes, jump.
mov dx, offset msg1; no, print error msg and exit.
jmp dev6

dev2:; Pick up double pointer to device
; Driver chain out of reserved
; Area in fcb. This area is mapped
; Differently in DOS 2.x and DOS 3.x.
cmp cl, 2; is this DOS 2.x?
ja dev3; no, jump.
mov bx, word ptr nulfcb +25
mov es, word ptr nulfcb +27
jmp dev4

dev3:; come here if DOS 3.0 or greater.
mov bx, word ptr nulfcb +26
mov es, word ptr nulfcb +28

dev4: call header; print sign-on message and
; Column headings.

dev5:; trace through the device chain

call prdev; print device header information
; For driver pointed to by ES: BX.
; Pick up addr of next header.
les bx, dword ptr es: [bx]
cmp bx, -1; found last one yet?
jne dev5; no, try next.

mov dx, offset msg3; yes, print "end of device chain".

dev6: 聽mov聽ah,9聽聽;print the string whose address
聽int聽21h聽聽;is in DX.
聽ret聽聽聽;then return to DOS.

dev聽聽 聽endp


header聽proc聽near聽聽;print out headings for device
聽mov聽dx,offset hdr聽;driver information.
聽mov聽ah,9
聽int聽21h
聽ret
header聽endp


prdev聽proc聽near聽聽;print out device driver info.
聽聽聽聽;ES:BX is pointer to device header,
聽聽聽聽;which must be preserved.
聽mov聽ax,es聽聽;convert segment of device header
聽mov聽di,offset inf1
聽call聽hexasc
聽mov聽ax,bx聽聽;convert offset of device header.
聽mov聽di,offset inf2
聽call聽hexasc
聽mov聽ax,es:[bx+4]聽;get attribute word, save a
聽push聽ax聽聽;copy of it, then convert it.
聽mov聽di,offset inf3
聽call聽hexasc
聽mov聽ax,es:[bx+6]聽;convert ptr to device strategy.
聽mov聽di,offset inf4
聽call聽hexasc
聽mov聽ax,es:[bx+8]聽;convert ptr to device int handler.
聽mov聽di,offset inf5
聽call聽hexasc

聽聽聽聽;if not char device, clear out name
聽聽聽聽;field and set number of units.
聽pop聽ax聽聽;get back attribute word.
聽test聽ax,08000h聽;is bit 15 = 1 ?
聽jnz聽prdev7聽聽;yes, it''s character dev, jump.
聽聽聽聽聽聽聽聽聽聽聽聽聽聽 聽聽;no, it''s block device.
聽聽聽聽;set flag to skip device name.
聽mov 聽byte ptr inf8,eom
聽mov聽al,es:[bx+10]聽;pick up number of units.
聽aam聽聽聽;convert to ASCII decimal and
聽add聽ax,''00''聽聽;store into output string.
聽mov聽byte ptr inf7+1,al
聽mov聽byte ptr inf7,ah
聽聽聽聽;set type = B for Block
聽mov聽byte ptr inf6,''B''聽
聽jmp聽prdev9

prdev7:聽聽聽聽;if char device, move its 8-character
聽聽聽聽;name into the output string.
聽xor聽si,si
prdev8:聽mov聽al,es:[si+bx+10]
聽mov聽[si+inf8],al
聽inc聽si
聽cmp聽si,8
聽jne聽prdev8
聽聽聽聽;remove # of units field.
聽mov聽word ptr inf7,''聽 ''
聽聽聽聽;set type = C for Character.
聽mov聽byte ptr inf6,''C''

prdev9: mov聽dx,offset inf聽;now print device information
聽mov聽ah,9聽聽;and exit.
聽int聽21h
聽ret
prdev聽endp

hexasc聽proc聽near聽聽;convert binary word to hex ASCII.
聽聽聽聽;call with AX=binary value
聽聽聽聽;聽聽聽聽聽聽聽聽聽 DI=addr to store string
聽聽聽聽;returns AX, CX, DI destroyed.
聽push聽ax聽聽;save copy of original value.
聽mov聽al,ah
聽call聽btoa聽聽;convert upper byte.
聽add聽di,2聽聽;increment output address.
聽pop聽ax
聽call聽btoa聽聽;convert lower byte.
聽ret聽聽聽;return to caller.
hexasc聽endp

btoa聽proc聽near聽聽;convert binary byte to hex ASCII.
聽聽聽聽;call with AL=binary value
聽聽聽聽;聽聽聽聽聽聽聽聽聽 DI=addr to store string
聽聽聽聽;returns AX, CX destroyed.
聽mov聽ah,al聽聽;save lower nibble.
聽mov聽cx,4聽聽;shift right 4 positions
聽shr聽al,cl聽聽;to get upper nibble.
聽call聽ascii聽聽;convert 4 bits to ASCII equivalent
聽mov聽[di],al聽聽;store into output string.
聽mov聽al,ah聽聽;get back lower nibble.
聽and聽al,0fh
聽call聽ascii聽聽;convert 4 bits to ASCII
聽mov聽聽聽聽 [di+1],al聽;and store into output string.
聽ret聽聽聽;back to caller.
btoa聽endp

ascii聽proc聽near聽聽;convert 4 lower bits of AL
聽add聽al,''0''聽聽;into the equivalent ASCII char.
聽cmp聽al,''9''聽聽;in the range {0...9,A...F}
聽jle聽ascii2聽聽;and return char. in AL.
聽add聽al,''A''-''9''-1聽;"fudge factor" for range A-F.
ascii2:聽ret聽聽聽;return to caller.
ascii聽endp

cseg聽聽聽 ends


data聽聽聽 segment para public ''DATA''

msg1聽db聽cr,lf
聽db聽''Failed to open NUL device.''
聽db聽cr,lf,eom

msg2聽聽聽 db聽聽聽聽聽 cr,lf
聽聽聽聽聽聽聽 db聽聽聽聽聽 ''Requires DOS version 2 or greater.''
聽聽聽聽聽聽聽 db聽聽聽聽聽 cr,lf,eom

msg3聽db聽cr,lf
聽db聽''End of device chain.''
聽db聽cr,lf,eom

hdr聽db聽cr,lf
聽db聽''Addr聽聽聽聽聽 Attr ''
聽db聽''Str聽 Int聽聽 Type聽 Units聽 Name聽聽 ''
聽db聽eom


inf 聽db聽cr,lf
inf1聽db聽''XXXX:''聽聽;seg device header
inf2聽db聽''XXXX ''聽聽;offs device header
inf3聽db聽''XXXX ''聽聽;attribute
inf4聽db聽''XXXX ''聽聽;strategy
inf5聽db聽''XXXX聽聽 ''聽;interrupt handler
inf6聽db聽''X聽聽聽聽 ''聽;type (block or char)
inf7聽db聽''XX聽聽聽 ''聽;units (if block device)
inf8聽db聽''聽聽聽聽聽聽聽聽 ''聽;name聽 (if char device)
聽db聽eom

聽聽聽聽;fcb to open NUL device
nulfcb聽db聽0聽聽;drive
聽db聽''NUL''聽聽;name of NUL device
聽db聽8 dup ('' '')
聽db聽25 dup (0)
data聽聽聽 ends聽聽聽


stack聽聽 segment para stack ''STACK''
聽聽聽聽聽聽聽 db聽聽聽聽聽 64 dup (?)
stack聽聽 ends

聽聽聽聽聽聽聽 end聽聽聽聽 dev






相关链接:



Pitou's Stingy articles - COMPREHENSIVE use of channel



Photoshop CS play magic, making the mysterious eye of the



Review Personal Interest



Premier Management And Distribution



ASF Converter



Photoshop plug-in filters



Tencent sued Staff: to protest the labor contract Tencent Overlord



BRIEF Remote Computing



"Tomato Garden" case of First instance pronounced loss of Chengdu, a total of over 10 million soft



Fireworks 4.0 Zhezhao Daquan ---- Second Class To Create A Bitmap Zhe Zhao



Server Applications Report



VOB to Zune



VOB to MPG



Graphics come from paint in



How GIS abstract surface features Of space?



To expose the fraud: WinRAR to compress 775MB 13.4MB



Seven Good Reasons For Products Not Sellers



No comments:

Post a Comment