庞大资源库的计算机教程网站!
设为首页
加入收藏
总编信箱
投稿或申请专栏请先 [登 陆]
首页 操作系统 程序设计 图形图像 媒体动画 机械电子 WEB开发 数 据 库 办公系列 路由技术 网络原理 网络应用
认证考试 安全技术
首页>程序设计>汇编语言>相关源码>正文
资料搜索
Google搜索
Google
返回上级列表

推荐文章

快速保存网页中所有图片的方法
Windows中让光驱巧妙“隐身”技
防范非法用户入侵Win 2000/XP系
两款比较典型的ASP木马防范方法
有关表格边框的css语法整理
Windows XP中可以被禁用的服务
SQL Server导出导入数据方法
Javascript所有对象的属性的获
网页(HTML)中的特殊字符
与篮球共舞,尽显模式本色
QQ病毒的手工清除方法
Photoshop为极品美女打造性感睫
天衣无缝:IIS与PHP水火也相容
SQL Server存储过程编写和优化

汇编的的各类源码--DEV

 作者:本站收集   日期:2005-8-1 15:39:19
字号选择〖 〗/ 双击滚屏 单击停止   
        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

上一篇:汇编的的各类源码--DOSMAC    下一篇:汇编的的各类源码--COMINT  
[发送给好友]  [关闭窗口]  [返回顶部]   转载请注明来源:www.it00.com   
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。
责任编辑: 原点 投稿作者: 本站收集
信息来源: 网络 录入时间: 2005-8-1 15:39:19
关于我们 - 广告服务 - 版权申明 - 网站地图 - 联系方式 - 总编信箱 - 会员投稿