敬业的IT人 >> 编程开发 >> 其他语言 >> 汇编源码--DEV

汇编源码--DEV

敬业的IT人 互联网 佚名 2008-2-19 14:32:23
    ·汇编源码--BRK
    ·汇编源码--CLOCK
    ·汇编源码--BURNOUT
    ·汇编源码--DOSSYM
    ·汇编源码--circle
    ·汇编源码--getspace
    ·汇编源码--CLEAR
    ·汇编源码--col
    ·汇编源码--gameport
    ·汇编源码--ctrladel
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 blankequ20h;ASCII space code eomequ'$';end of string marker csegsegmentpara public 'CODE' assumecs: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 movds,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. jmpdev6 dev1:movcx,ax;save DOS version number. movah,15;now try and open the "NUL" device. movdx,offset nulfcb int21h oral,al;opened successfully? jzdev2;yes, jump. movdx,offset msg1;no, print error msg and exit. jmpdev6 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. cmpcl,2;is this DOS 2.x? jadev3;no, jump. movbx,word ptr nulfcb+25 moves,word ptr nulfcb+27 jmpdev4 dev3:;come here if DOS 3.0 or greater. movbx,word ptr nulfcb+26 moves,word ptr nulfcb+28 dev4:callheader;print sign-on message and ;column headings. dev5:;trace through the device chain callprdev;print device header information ;for driver pointed to by ES:BX. ;pick up addr of next header. lesbx,dword ptr es:[bx] cmpbx,-1;found last one yet? jnedev5;no, try next. movdx,offset msg3;yes, print "end of device chain". dev6: movah,9;print the string whose address int21h;is in DX. ret;then return to DOS. dev endp headerprocnear;print out headings for device movdx,offset hdr;driver information. movah,9 int21h ret headerendp prdevprocnear;print out device driver info. ;ES:BX is pointer to device header, ;which must be preserved. movax,es;convert segment of device header movdi,offset inf1 callhexasc movax,bx;convert offset of device header. movdi,offset inf2 callhexasc movax,es:[bx+4];get attribute word, save a pushax;copy of it, then convert it. movdi,offset inf3 callhexasc movax,es:[bx+6];convert ptr to device strategy. movdi,offset inf4 callhexasc movax,es:[bx+8];convert ptr to device int handler. movdi,offset inf5 callhexasc ;if not char device, clear out name ;field and set number of units. popax;get back attribute word. testax,08000h;is bit 15 = 1 ? jnzprdev7;yes, it's character dev, jump. ;no, it's block device. ;set flag to skip device name. mov byte ptr inf8,eom moval,es:[bx+10];pick up number of units. aam;convert to ASCII decimal and addax,'00';store into output string. movbyte ptr inf7+1,al movbyte ptr inf7,ah ;set type = B for Block movbyte ptr inf6,'B' jmpprdev9 prdev7:;if char device, move its 8-character ;name into the output string. xorsi,si prdev8:moval,es:[si+bx+10] mov[si+inf8],al incsi cmpsi,8 jneprdev8 ;remove # of units field. movword ptr inf7,' ' ;set type = C for Character. movbyte ptr inf6,'C' prdev9: movdx,offset inf;now print device information movah,9;and exit. int21h ret prdevendp hexascprocnear;convert binary word to hex ASCII. ;call with AX=binary value ; DI=addr to store string ;returns AX, CX, DI destroyed. pushax;save copy of original value. moval,ah callbtoa;convert upper byte. adddi,2;increment output address. popax callbtoa;convert lower byte. ret;return to caller. hexascendp btoaprocnear;convert binary byte to hex ASCII. ;call with AL=binary value ; DI=addr to store string ;returns AX, CX destroyed. movah,al;save lower nibble. movcx,4;shift right 4 positions shral,cl;to get upper nibble. callascii;convert 4 bits to ASCII equivalent mov[di],al;store into output string. moval,ah;get back lower nibble. andal,0fh callascii;convert 4 bits to ASCII mov [di+1],al;and store into output string. ret;back to caller. btoaendp asciiprocnear;convert 4 lower bits of AL addal,'0';into the equivalent ASCII char. cmpal,'9';in the range {0...9,A...F} jleascii2;and return char. in AL. addal,'A'-'9'-1;"fudge factor" for range A-F. ascii2:ret;return to caller. asciiendp cseg ends data segment para public 'DATA' msg1dbcr,lf db'Failed to open NUL device.' dbcr,lf,eom msg2 db cr,lf db 'Requires DOS version 2 or greater.' db cr,lf,eom msg3dbcr,lf db'End of device chain.' dbcr,lf,eom hdrdbcr,lf db'Addr Attr ' db'Str Int Type Units Name ' dbeom inf dbcr,lf inf1db'XXXX:';seg device header inf2db'XXXX ';offs device header inf3db'XXXX ';attribute inf4db'XXXX ';strategy inf5db'XXXX ';interrupt handler inf6db'X ';type (block or char) inf7db'XX ';units (if block device) inf8db' ';name (if char device) dbeom ;fcb to open NUL device nulfcbdb0;drive db'NUL';name of NUL device db8 dup (' ') db25 dup (0) data ends stack segment para stack 'STACK' db 64 dup (?) stack ends end dev 进入讨论组讨论。
粤ICP备06119539号
Copyright CiscoSky.Org,Some Rights Reserved.
Email:me1228#tom.com