王爽.汇编.第三版.实验16.答案

来源:互联网 发布:飞秋2013正式版 mac版 编辑:程序博客网 时间:2024/04/30 08:16
; int 7c中断例程; assume  cs:codecode segmentstart:    ; 拷贝代码    mov ax, 0    mov es, ax    mov ax, 200h    mov di, ax    push cs    pop ds    mov ax, offset int7c    mov si, ax    mov cx, offset int7c_end - offset int7c    cld    rep movsb    cli    mov ax, 0    mov ds, ax    mov bx, 07ch*4    mov word ptr ds:[bx], 200h    mov word ptr ds:[bx+2], 0    sti    mov ax, 4c00h    int 21hint7c:    jmp short int7c_code    ; 注意此处放的是放在绝对地址0:200时,子程序处于的相对地址,    ; 此方法不好,因为如果程序不是安装在0:200,就会出错    ; 当如如果直接jmp到标号,是没有问题的    table dw sub1-int7c+200h, sub2-int7c+200hint7c_code:    push ax     push bx    ; 功能号    cmp ah, 1    ja int7c_ok    sub bx, bx    mov bl, ah    add bx, bx    push cs    pop ds    ; 200是本中断代码的起始地址,2:是jmp指令的长度。bx索引到相应table位置    call word ptr [bx+200h+2]int7c_ok:    pop bx    pop ax    iret    ; clear screensub1:    push bx    push cx    push es    mov bx, 0b800h    mov es, bx    mov bx, 0    mov cx, 2000sub1s:    mov byte ptr es:[bx], ' '    add bx, 2    loop sub1s    pop es    pop cx    pop bx    ret    ; change text colorsub2:    push bx    push cx    push es    mov bx, 0b800h    mov es, bx    mov bx, 1    mov cx, 2000sub2s:    and byte ptr es:[bx], 11111000b    or byte ptr es:[bx], al    add bx, 2    loop sub2s    pop es    pop cx    pop bx    retsuberror:    retint7c_end:    nopcode endsend start
原创粉丝点击