xiaosawanjava 发表于 2014-6-9 16:47:05

实验16


assume cs:code

code segment

start:
;0清屏,1 前景色2 背景色3 上滚动
;ah功能   al 颜色
MOV AH,1
MOV AL,01010000b
INT 7ch


mov ax,4c00h
int 21h

code ends
end start


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:,200h
MOV WORD ptr DS:,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:
    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:,' '
      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:,11111000b
      OR ES:,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:,10001111b
      OR ES:,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 ,' '
      ADD DI,2
    LOOP s4

    POP CX
    POP DI
    POP SI
    POP ES
    POP DS
    POP AX
    RET
int7chEnd:nop

code ends
end start

页: [1]
查看完整版本: 实验16