assume cs:code
code segment
start:
MOV AX,CS
MOV DS,AX
MOV SI,offset int7chStart
MOV AX,0
MOV ES,AX
MOV DI,200h
MOV CX,offset int7chEnd-offset int7chStart
CLD
REP movsb
MOV AX,0
MOV DS,AX
MOV WORD ptr DS:[7ch*4],200h
MOV WORD ptr DS:[7ch*4+2],0
mov ax,4c00h
int 21h
int7chStart:
JMP short ok
;qingping标记这里偏移是根据 当前cs:0 偏移位置,而我们要把这段程序写到 o:200的位置去,所以要-a+202h 为什么不是加+200h是因为 jmp short ok这里占了2个字节
; 也可以这样写 a DW qingping-int7chStart+200h,qianjingse-int7chStart+200h,beijingse-int7chStart+200h,shanggundong-int7chStart+200h
a DW qingping-a+202h,qianjingse-a+202h,beijingse-a+202h,shanggundong-a+202h
ok:
PUSH AX
PUSH DS
PUSH bx
PUSH AX
MOV AX,CS
MOV DS,AX
POP AX
MOV BH,0
ADD AH,AH
MOV BL,AH
CALL WORD ptr CS:[bx+202h]
POP bx
POP DS
POP AX
IRET
;清屏
qingping:
PUSH AX
PUSH ES
PUSH SI
PUSH CX
MOV AX,0b800h
MOV ES,AX
MOV SI,0
MOV CX,2000
s:
MOV BYTE ptr ES:[si],' '
ADD SI,2
LOOP s
POP CX
POP SI
POP ES
POP AX
RET
;前景色
qianjingse:
PUSH AX
PUSH ES
PUSH SI
PUSH CX
PUSH AX
MOV AX,0b800h
MOV ES,AX
MOV SI,1
POP AX
MOV CX,2000
s1:
AND BYTE ptr ES:[si],11111000b
OR ES:[SI],AL
ADD SI,2
LOOP s1
POP CX
POP SI
POP ES
POP AX
RET
;背景色
beijingse:
PUSH AX
PUSH ES
PUSH SI
PUSH CX
PUSH AX
MOV AX,0b800h
MOV ES,AX
MOV SI,1
POP AX
MOV CX,2000
s2:
AND BYTE ptr ES:[si],10001111b
OR ES:[SI],AL
ADD SI,2
LOOP s2
POP CX
POP SI
POP ES
POP AX
RET
;上滚动
shanggundong:
PUSH AX
PUSH DS
PUSH ES
PUSH SI
PUSH DI
PUSH CX
MOV AX,0b800h
MOV DS,AX
MOV ES,AX
MOV SI,160
MOV DI,0
MOV CX,24
CLD
s3:
PUSH CX
MOV CX,160
REP movsb
POP CX
LOOP s3
MOV CX,160
s4:
MOV BYTE ptr [di],' '
ADD DI,2
LOOP s4
POP CX
POP DI
POP SI
POP ES
POP DS
POP AX
RET
int7chEnd:nop
code ends
end start