首页 > 编程 > ASM > 正文

汇编语言直接定指标的应用实验16代码

2019-11-10 18:36:21
字体:
来源:转载
供稿:网友

代码解释如下:

;汇编语言王爽  直接定址表  实验16 assume cs:code,ds:data,ss:stackdata segment	db 128 dup(0)data  endsstack segment	db 128 dup(0)stack endscode segmentstart:				mov ax,stack					mov ss,ax					mov sp,128					call cpy_newInt7ch			;复制定义的新的int7ch中断处理程序					call set_newInt7ch			;设置中断向量表					mov ah,2					;初始化参数,执行哪个子程序					mov al,10111010B			;al存颜色参数					int 7ch						;执行7ch中断程序					mov ax,4c00h					int 21h;=========================================================	设置新的中断程序new_int7ch:			jmp newInt7chStartTABLE				dw offset clear_screen 	- 	offset new_int7ch +7e00h	;记录每个子程序的入口地址,参数0					dw offset set_PRe_screen - 	offset new_int7ch +7e00h	;参数1					dw offset set_back_screen - offset new_int7ch +7e00h	;参数2										dw offset set_up_scroll - 	offset new_int7ch +7e00h	;参数3newInt7chStart:		push bx					push es					push ax										mov bx,0					mov es,bx					mov bl,ah					add bx,bx					;存储程序地址的是双字,所以bx加倍					add bx,offset TABLE - offset new_int7ch + 7e00h					call Word ptr es:[bx]										pop ax					pop es					pop bx					iret										;中断程序用iret返回					;=========================================================		清屏					clear_screen:		push cx					push bx					push es					push di					mov cx,2000					mov bx,0b800h					mov es,bx					mov di,0clearScreen:		mov es:[di],0700h					add di,2					loop clearScreen										pop di					pop es					pop bx					pop cx					ret;=========================================================		设置前景色set_pre_screen:		push cx					push bx					push es					push ax					mov cx,2000					mov bx,0b800h					mov es,bx					mov bx,1changePreColor:		and byte ptr es:[bx],11111000B					or byte ptr es:[bx],al					add bx,2					loop changePreColor										pop ax					pop es					pop bx					pop cx					ret;=========================================================		设置背景色set_back_screen:	push cx					push bx					push es					push ax										mov cx,2000					mov bx,0b800h					mov es,bx					mov bx,1changeBackColor:	and byte ptr es:[bx],10001111B					or byte ptr es:[bx],al					add bx,2					loop changeBackColor										pop ax					pop es					pop bx					pop cx					ret;=========================================================		向上滚动一行set_up_scroll:		push bx					push es					push ds					push di					push si					push cx										mov bx,0b800h					mov es,bx					mov ds,bx					mov di,0					mov si,160					mov cx,24*160					rep movsb					mov cx,80setNull:			mov di,160*24								;设置最后一行为空					mov es:[di],0700h					add di,2					loop setNull										pop cx					pop si					pop di					pop ds					pop es					pop bx					ret;=========================================================					new_int7chEnd:		nop					;========================================================== 	复制中断程序cpy_newInt7ch:		push ax					push ds					push si					push es					push di					push cx										mov ax,cs					mov ds,ax					mov si,offset new_int7ch					mov ax,0					mov es,ax					mov di,7e00h					mov cx,offset new_int7chEnd - offset new_int7ch					cld											;每次执行后si,di加 1,					rep movsb										pop cx					pop di					pop es					pop si					pop ds					pop ax					ret;==========================================================	设置中断向量表set_newInt7ch:		mov ax,0					mov es,ax					cli					mov word ptr es:[7ch*4],7e00h			;设置ip = 7e00					mov word ptr es:[7ch*4+2],0				;设置cs = 0000					sti					ret;==========================================================			code endsend start


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表

图片精选