assume cs:codesg,ss:stacksg stacksg segment db 128 dup(0) stacksg ends codesg segment int7ch_start:jmp int_main ;-----------------------------------------清空屏幕 ck:push bx push cx push es mov bx,0b800h mov es,bx mov bx,0 mov cx,2000 ck_s
- assume cs:codesg,ss:stacksg
- stacksg segment
- db 128 dup(0)
- stacksg ends
- codesg segment
- int7ch_start:jmp int_main
- ;-----------------------------------------清空屏幕
- ck:push bx
- push cx
- push es
- mov bx,0b800h
- mov es,bx
- mov bx,0
- mov cx,2000
- ck_s:mov byte ptr es:[bx],' ';清空屏幕
- add bx,2
- loop ck_s
- pop es
- pop cx
- pop bx
- ret
- ;-----------------------------------------设置前景
- qj:push bp
- mov bp,sp
- push ax
- push cx
- push bx
- push es
- cmp byte ptr ss:4h[bp],7h;颜色值大于7就不干...
- ja qj_e
- mov ax,0b800h
- mov es,ax
- mov ax,ss:4h[bp]
- mov bx,1
- mov cx,2000
- qj_s:and byte ptr es:[bx],11111000b;前景色置0
- or byte ptr es:[bx],al;设置前景色
- add bx,2h
- loop qj_s
- qj_e:pop es
- pop bx
- pop cx
- pop ax
- pop bp
- ret
- ;-----------------------------------------设置背景
- bj:push bp
- mov bp,sp
- push ax
- push cx
- push bx
- push es
- cmp byte ptr ss:4h[bp],7h;颜色值大于7就不干...
- ja bj_e
- mov ax,0b800h
- mov es,ax
- mov ax,ss:4h[bp]
- mov cl,4
- shl al,cl;左移4位
- mov bx,1
- mov cx,2000
- bj_s:and byte ptr es:[bx],10001111b;背景色置0
- or byte ptr es:[bx],al;设置背景色
- add bx,2h
- loop bj_s
- bj_e:pop es
- pop bx
- pop cx
- pop ax
- pop bp
- ret
- ;-----------------------------------------滚动一行
- gd:push ds
- push es
- push si
- push di
- push cx
- push ax
- mov ax,0b800h
- mov es,ax
- mov di,0
- mov ds,ax
- mov si,160
- cld;递增
- mov cx,24
- gd_s:push cx
- push si
- push di
- mov cx,160
- rep movsb;复制
- pop di
- pop si
- add di,160
- add si,160
- pop cx
- loop gd_s
- pop ax
- pop cx
- pop di
- pop si
- pop es
- pop ds
- ret
- int_main:jmp codemain
- fun_table dw ck-int7ch_start,qj-int7ch_start,bj-int7ch_start,gd-int7ch_start;功能列表(数据标号,因为地址在编译时固定了,所以只能拿偏移了...)
- codemain:push di;ax是参数ah功能号al是颜色参数
- push bx
- push si
- cmp ah,3;检查非法操作
- ja int7ch_o
- mov bx,0
- mov bl,ah
- add bx,bx
- mov si,bx;获取功能号
- mov bx,fun_table-int7ch_start
- mov bx,cs:200h[bx][si];获取功能地址
- add bx,200h;
- push ax
- call bx
- pop ax
- int7ch_o:pop si
- pop bx
- pop di
- iret
- int7ch_end:nop
- start:mov ax,stacksg
- mov ss,ax
- mov sp,128
- mov ax,cs;复制代码
- mov ds,ax
- mov ax,0
- mov es,ax
- mov si,offset int7ch_start
- mov di,200h
- mov cx,offset int7ch_end-offset int7ch_start
- rep movsb
- mov ax,0;安装7ch中断例程
- mov es,ax
- mov word ptr es:[7ch*4],200h
- mov word ptr es:[7ch*4+2],0h
- mov ah,2;功能(0,1,2,3)
- mov al,2;颜色(0,1,2,3,4,5,6,7)
- int 7ch;调用
- mov ax,4c00h
- int 21h
- codesg ends
- end start