1 assume cs:code 2 ;中断例程 3 code segment 4 start: 5 mov ax,cs 6 mov ds,ax 7 mov si,offset setscreen 8 mov ax,0020H 9 mov es,ax 10 mov di,0 11 12 mov cx,offset over-offset setscreen 13 cld 14 rep movsb ;复制段 15 16 mov ax,0 17 mov es,ax 18 mov word ptr es:[7cH*4],0 19 mov word ptr es:[7cH*4+2],0020H ;入口地址段 20 21 mov ax,4c00H 22 int 21H 23 24 setscreen: ;选择子程序 25 sub: 26 jmp short set 27 dw offset sub1-sub,offset sub2-sub,offset sub3-sub,offset sub4-sub 28 set: 29 push bx 30 31 cmp ah,3 32 ja sret 33 mov bl,ah 34 mov bh,0 35 add bx,bx 36 37 call word ptr cs:[2+bx] 38 sret: 39 pop bx 40 iret 41 42 sub1: ;清屏 43 push bx 44 push cx 45 push es 46 47 mov bx,0b800H 48 mov es,bx 49 mov bx,0 50 mov cx,2000 51 sub1s: 52 mov byte ptr es:[bx],' ' 53 add bx,2 54 loop sub1s 55 56 pop es 57 pop cx 58 pop bx 59 ret 60 61 sub2: ;显示背景色 62 push bx 63 push cx 64 push es 65 66 mov bx,0b800H 67 mov es,bx 68 mov bx,1 69 mov cx,2000 70 sub2s: 71 and byte ptr es:[bx],11111000B 72 or es:[bx],al 73 add bx,2 74 loop sub2s 75 76 pop es 77 pop cx 78 pop bx 79 ret 80 81 sub3: ;显示前景色 82 push bx 83 push cx 84 push es 85 86 mov cl,4 87 shl al,cl 88 mov bx,0b800H 89 mov es,bx 90 mov bx,1 91 mov cx,2000 92 sub3s: 93 and byte ptr es:[bx],10001111B 94 or es:[bx],al 95 add bx,2 96 loop sub3s 97 98 pop es 99 pop cx 100 pop bx 101 ret 102 103 sub4: ;上卷 104 push cx 105 push si 106 push di 107 push es 108 push ds 109 110 mov si,0b800H 111 mov es,si 112 mov di,si 113 mov si,0100H 114 mov di,0 115 cld 116 mov cx,24 117 sub4s: 118 push cx 119 mov cx,0100H 120 rep movsb 121 pop cx 122 loop sub4s 123 124 mov cx,80 125 mov si,0 126 sub4s1: 127 mov byte ptr [160*24+si],' ' 128 add si,2 129 loop sub4s1 130 131 pop ds 132 pop es 133 pop di 134 pop si 135 pop cx 136 ret 137 138 over: 139 nop 140 141 code ends 142 143 end start
1 assume cs:code 2 ;中断例程2 3 code segment 4 start: 5 mov ax,cs 6 mov ds,ax 7 mov si,offset setscreen 8 mov ax,0020H 9 mov es,ax 10 mov di,0 11 12 mov cx,offset over-offset setscreen 13 cld 14 rep movsb ;复制段 15 16 mov ax,0 17 mov es,ax 18 mov word ptr es:[7cH*4],0 19 mov word ptr es:[7cH*4+2],0020H ;入口地址段 20 21 mov ax,4c00H 22 int 21H 23 24 setscreen: ;选择子程序 25 jmp short set 26 set: 27 push bx 28 29 cmp ah,3 30 ja sret 31 mov bl,ah 32 mov bh,0 33 add bx,bx 34 35 mov dx,offset sret-setscreen ;做距离差 36 cmp bx,0 ;选择0 37 je sub1 38 cmp bx,2 ;选择1 39 je sub2 40 cmp bx,4 ;选择2 41 je sub3 42 cmp bx,6 ;选择3 43 je sub4 44 sret: 45 pop bx 46 iret 47 48 sub1: ;清屏 49 push bx 50 push cx 51 push es 52 53 mov bx,0b800H 54 mov es,bx 55 mov bx,0 56 mov cx,2000 57 sub1s: 58 mov byte ptr es:[bx],' ' 59 add bx,2 60 loop sub1s 61 62 pop es 63 pop cx 64 pop bx 65 push dx 66 ret 67 68 sub2: ;显示背景色 69 push bx 70 push cx 71 push es 72 73 mov bx,0b800H 74 mov es,bx 75 mov bx,1 76 mov cx,2000 77 sub2s: 78 and byte ptr es:[bx],11111000B 79 or es:[bx],al 80 add bx,2 81 loop sub2s 82 83 pop es 84 pop cx 85 pop bx 86 push dx 87 ret 88 89 sub3: ;显示前景色 90 push bx 91 push cx 92 push es 93 94 mov cl,4 95 shl al,cl 96 mov bx,0b800H 97 mov es,bx 98 mov bx,1 99 mov cx,2000 100 sub3s: 101 and byte ptr es:[bx],10001111B 102 or es:[bx],al 103 add bx,2 104 loop sub3s 105 106 pop es 107 pop cx 108 pop bx 109 push dx 110 ret 111 112 sub4: ;上卷 113 push cx 114 push si 115 push di 116 push es 117 push ds 118 119 mov si,0b800H 120 mov es,si 121 mov di,si 122 mov si,0100H 123 mov di,0 124 cld 125 mov cx,24 126 sub4s: 127 push cx 128 mov cx,0100H 129 rep movsb 130 pop cx 131 loop sub4s 132 133 mov cx,80 134 mov si,0 135 sub4s1: 136 mov byte ptr [160*24+si],' ' 137 add si,2 138 loop sub4s1 139 140 pop ds 141 pop es 142 pop di 143 pop si 144 pop cx 145 push dx 146 ret 147 148 over: 149 nop 150 151 code ends 152 153 end start
1 assume cs:code 2 ;测试程序 3 code segment 4 start: 5 mov ah,1 ;启用功能1 6 mov al,01001000B ;背景颜色为红色高亮 7 int 7cH 8 9 mov ax,4c00H 10 int 21H 11 12 code ends 13 14 end start