assume cs:code
stack segment stack
dw 32 dup(0)
stack ends
code segment
start: mov ax, cs
mov ds, ax
mov si, offset int7ch
xor ax, ax
mov es, ax
mov di, 200h
mov cx, offset int7chend - offset int7ch
cld
rep movsb
cli
mov word ptr es:[7ch * 4], 200h
mov word ptr es:[7ch * 4 + 2], 0h
sti
mov ax, 4c00h
int 21h
int7ch: jmp short screenstart
dw sub1 - int7ch + 200h, sub23 - int7ch + 200h, sub23 - int7ch + 200h, sub4 - int7ch + 200h
screenstart:
push bx
cmp ah, 3
ja quit
mov bl, ah
xor bh, bh
add bx, bx
call word ptr cs:[bx + 202h]
quit: pop bx
iret
sub1: push cx
push ds
push si
mov si, 0b800h
mov ds, si
mov si, 0
mov cx, 4000h
sub1s: mov byte ptr [si], 0
add si, 2
loop sub1s
pop si
pop ds
pop cx
ret
; 子程序2和3的功能类似,合并为一了
sub23: push bx
push cx
push ds
push si
jmp sub23switch
submask db 11111000b, 10001111b ; 色彩掩码
bits db 0, 4 ; 移动位数
sub23switch:
mov bx, 0b800h
mov ds, bx
mov si, 1
mov bl, ah
xor bh, bh
shr bx, 1 ; 这里是将1和2对应为0和1
; 假如修改背景色,al是要左移4位的
mov cl, cs:[bits - int7ch + 200h][bx]
shl al, cl
mov bl, cs:[submask - int7ch + 200h][bx]
mov cx, 2000h
sub23s: and [si], bl
or [si], al
add si, 2
loop sub23s
pop si
pop ds
pop cx
pop bx
ret
sub4: push cx
push ds
push es
push si
push di
mov si, 0b800h
mov ds, si
mov es, si
mov si, 80 * 2
mov di, 0
cld
mov cx, 24
sub4s: push cx
mov cx, 160
rep movsb
pop cx
loop sub4s
mov cx, 80
sub4s1: mov byte ptr [di], 0
add si, 2
loop sub4s1
pop di
pop si
pop es
pop ds
pop cx
ret
int7chend:
nop
code ends
end start