汇编程序50:检测点15.1(1)
1 assume cs:code 2 ;在屏幕处显示字符'a'变化到'z',并随时接受按键esc变化其颜色属性 3 stack segment 4 db 128 dup(0) 5 stack ends 6 7 data segment 8 dw 0,0 9 data ends 10 11 code segment 12 start: 13 mov ax,stack 14 mov ss,ax 15 mov sp,128 16 17 mov ax,data 18 mov ds,ax 19 20 mov ax,0 21 mov es,ax 22 23 push es:[9*4] 24 pop ds:[0] 25 push es:[9*4+2] 26 pop ds:[2] ;把程序结束前需归还的原按键例程入口地址储存到数据段 27 28 mov word ptr es:[9*4],offset int9 29 mov es:[9*4+2],cs ;设置中断例程入口地址 30 31 mov ax,0b800h 32 mov es,ax 33 mov ah,'a' 34 s: 35 mov es:[12*160+40*2],ah 36 call delay 37 inc ah 38 cmp ah,'z' 39 jna s ;在屏幕上显示从字符'a'到'z' 40 41 mov ax,0 42 mov es,ax 43 44 push ds:[0] 45 pop es:[9*4] 46 push ds:[2] 47 pop es:[9*4+2] ;把原按键例程的入口地址归还给向量的中断向量表 48 49 mov ax,4c00h 50 int 21h 51 52 delay: ;延迟子程序 53 push ax 54 push dx 55 mov dx,10h 56 mov ax,0 57 s1: 58 sub ax,1 59 sbb dx,0 60 cmp ax,0 61 jne s1 62 cmp dx,0 63 jne s1 64 pop dx 65 pop ax 66 ret
6x 67 int9: ;新int9中断例程 68 push ax 69 push bx 70 push es 71 72 in al,60h //从接口卡芯片处等待接受按键信息 73 74 pushf 75 call dword ptr ds:[0] ;精简的2行代码 76 cmp al,1 77 jne int9ret 78 mov ax,0b800h 79 mov es,ax 80 inc byte ptr es:[12*160+40*2+1] ;字符颜色变化 81 82 int9ret: 83 pop es 84 pop bx 85 pop ax 86 iret 87 88 code ends 89 90 end start