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

推荐文章

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

汇编的的各类源码--dskwatch

 作者:本站收集   日期:2005-8-1 15:39:15
字号选择〖 〗/ 双击滚屏 单击停止   
; By Steve Holzner (from June 11, 1985 issue of PC Magazine)

interrupts	segment at 0h	; This is where the disk interrupt
	org	13h*4		; holds the address of its service routine
disk_int	label	dword
interrupts	ends

screen	segment at 0B000h	; A dummy segment to use as the Extra
screen	ends			; Segment so we can write to the display

code_seg	segment
	assume	cs:code_seg
	org	0100h		; ORG = 100h to make this a .COM file
first:	jmp	load_watch	; First time through jump to initialize routine

	msg_part_1	db	'Disk error: '	; Here are the error messages
	msg_part_2	db	'No response Failed Seek NEC Error   '
			db	'Bad CRC SeenDMA Overrun Impos Sector'
			db	'No Addr MarkW. ProtectedErr Unknown '
	first_position	dw	?		; Position of 1st char on screen
	flags		dw	?
	screen_seg_offset dw	0		; 0 for mono, 8000h for graphics
	old_disk_int	dd	?		; Location of old disk interrupt
	ret_addr	label dword		; Used in fooling around with
	ret_addr_word	dw 2 dup(?)		;   the stack

disk_watch	proc	far	; The disk interrupt will now come here
	assume	cs:code_seg
	pushf			; First, call old disk interrupt
	call	old_disk_int
	pushf			; Save the flags in memory location "FLAGS"
	pop	flags		; (cunning name)
	jc	error		; If there was an error, carry flag will have
	jmp	fin		;  been set by Disk Interrupt
error:	push	ax		; AH has the status of the error
	push	cx		; Push all used registers for politeness
	push	dx
	push	di
	push	si
	push	es
	lea	si,msg_part_1	; Always print "Disk Error: " part.
	assume	es:screen	; Use screen as extra segment
	mov	dx,screen
	mov	es,dx
	mov	di,screen_seg_offset	; DI will be pointer to screen position
	add	di,first_position	; Add to point to desired area on screen
	call	write_to_screen		; This writes 12 chars from [SI] to [DI]
	mov	dx,80h			; Initialize for later comparisons
	mov	cx,7			; Loop seven times
e_loop:	cmp	ah,dh			; Are error code and DH the same?
	je	e_found			; If yes, Error has been found
	add	si,12			; Point to next error message
	shr	dh,1			; Divide DH by 2
	loop	e_loop			; Keep going until matched  DH = 0
	cmp	ah,3			; Error code no even number; 3 perhaps?
	je	e_found			; If yes, have found the error
	add	si,12			; Err unknown; unknown error returned
e_found:call	write_to_screen		; Write the error message to the screen
	pop	es		; Restore the registers
	pop	si
	pop	di
	pop	dx
	pop	cx
	pop	ax
fin:	pop	ret_addr_word		; Fooling with the stack. We want to
	pop	ret_addr_word[2]	; preserve the flags but the old flags
	add	sp,2			; are still on the stack. First remove
	push	flags			; return address, then flags. Fill flags
	popf				; from "FLAGS", return to correct addr.
	jmp	ret_addr
disk_watch	endp

write_to_screen	proc	near	; Puts 12 characters on screen
	mov	cx,12		; Loop 12 times
w_loop:	movs	es:byte ptr[di],cs:[si] ; Move to the screen
	mov	al,7		; Move screen attribute into screen buffer
	mov	es:[di],al
	inc	di		; Point to next byte in screen buffer
	loop	w_loop		; Keep going until done
	ret
write_to_screen	endp

load_watch	proc	near	; This procedure initializes everything
	assume	ds:interrupts	; The data segment will be the interrupt area
	mov	ax,interrupts
	mov	ds,ax

	mov	ax,disk_int	; Get the old interrupt service routine
	mov	old_disk_int,ax	; address and put it into our location
	mov	ax,disk_int[2]	; OLD_DISK_INT so we can call it.
	mov	old_disk_int[2],ax

	mov	disk_int,offset disk_watch  ; Now load the address of DskWatch
	mov	disk_int[2],cs		; routine into the disk interrupt

	mov	ah,15		; Ask for service 15 of INT 10h
	int	10h		; This tells us how display is set up
	sub	ah,25		; Move to twenty five places before edge
	shl	ah,1		; Mult. by two (char & attribute bytes)
	mov	byte ptr first_position,ah	; Set screen cursor
	test	al,4		; Is it a monochrome display?
	jnz	exit		; Yes - jump out
	mov	screen_seg_offset,8000h	; No, set up for graphics display
exit:	mov	dx,offset load_watch	; Set up everything but this program to
	int	27h			; stay and attach itself to DOS
load_watch	endp
	code_seg	ends
	end	first	; END "FIRST" so 8088 will go to FIRST first.

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