汇编程序45:检测点13.2 (loop指令的中断例程)
1 安装程序: 2 assume cs:code 3 //loop指令的替代实现 4 code segment 5 start: 6 mov ax,cs 7 mov ds,ax 8 mov si,offset sub1 9 mov ax,0020h 10 mov es,ax 11 mov di,0 12 mov bx,offset sub2 - offset sub1 13 cld 14 rep movsb 15 mov ax,0 16 mov es,ax 17 mov word ptr es:[7ch*4],200h 18 mov word ptr es:[7ch*4+2],0 19 mov ax,4c00h 20 int 21h 21 sub1: 22 push bp 23 mov bp,sp 24 dec cx 25 jcxz s0 26 add [bp+2],bx 27 s0: 28 pop bp 29 iret 30 sub2: 31 nop 32 code ends 33 34 end start
1 测试程序: 2 assume cs:code 3 //将80个!显示在屏幕上 4 code segment 5 start: 6 mov ax,0b800h 7 mov es,ax 8 mov di,12*160 9 mov bx,offset s - offset se 10 mov cx,80 11 s: 12 mov byte ptr es:[di],'!' 13 add di,2 14 int 7ch //安装程序,实现loop s功能 15 se: 16 mov ax,4c00h 17 int 21h 18 code ends 19 20 end start