AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > 汇编语言

汇编源码--DEV

51自学网 2015-09-08 http://www.51zixue.net
        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 Duncancr      equ     0dh             ;ASCII carriage returnlf      equ     0ah             ;ASCII line feedblank	equ	20h		;ASCII space codeeom	equ	'$'		;end of string markercseg	segment	para public 'CODE'	assume	cs:cseg,ds:data,es:data,ss:stackdev 	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	dev6dev1:	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	dev6dev2:				;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	dev4dev3:				;come here if DOS 3.0 or greater.	mov	bx,word ptr nulfcb+26	mov	es,word ptr nulfcb+28dev4:	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   	endpheader	proc	near		;print out headings for device	mov	dx,offset hdr	;driver information.	mov	ah,9	int	21h	retheader	endpprdev	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	prdev9prdev7:				;if char device, move its 8-character				;name into the output string.	xor	si,siprdev8:	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	retprdev	endphexasc	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	endpbtoa	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	endpascii	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	endpcseg    endsdata    segment para public 'DATA'msg1	db	cr,lf	db	'Failed to open NUL device.'	db	cr,lf,eommsg2    db      cr,lf        db      'Requires DOS version 2 or greater.'        db      cr,lf,eommsg3	db	cr,lf	db	'End of device chain.'	db	cr,lf,eomhdr	db	cr,lf	db	'Addr      Attr '	db	'Str  Int   Type  Units  Name   '	db	eominf 	db	cr,lfinf1	db	'XXXX:'		;seg device headerinf2	db	'XXXX '		;offs device headerinf3	db	'XXXX '		;attributeinf4	db	'XXXX '		;strategyinf5	db	'XXXX   '	;interrupt handlerinf6	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 devicenulfcb	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

 

 

 
上一篇:汇编源码--COBLOAD  下一篇:汇编源码--COMINT