王爽《汇编语言》实验16(自动测试版)

assume cs:code,ss:stack
stack segment
 db 128 dup (0)
stack ends
;===============install new int7ch
code segment 
start:  mov ax,code
        mov ds,ax
        mov si,offset newint7ch
       	mov ax,0
       	mov es,ax
       	mov di,200h

       	mov cx,offset newint7ch_end-offset newint7ch
       	cld
       	rep movsb
       	cli
       	mov word ptr es:[7ch*4],200h
       	mov word ptr es:[7ch*4+2],0
       	sti
 ;-------------------------tset newint7ch       
        mov ah,0         ;test 1
       	int 7ch
        call delay

       	mov ah,1         ;test 2
       	mov al,6
       	int 7ch
        call delay

        mov ah,2         ;test 3
      	mov al,1
      	int 7ch
        call delay

       	mov bx,0b800h    ;test 4
       	mov es,bx
       	mov di,80
       	mov bl,'a'
       	mov cx,24
 test4s:mov byte ptr es:[di],bl
        add di,160
       	inc bx
       	loop test4s
       	mov ah,3
       	int 7ch
        call delay 

       	mov ax,4c00h
       	int 21h
;-------------------------------
delay:  push ax
        push dx
        mov dx,77h           
       	mov ax,0
delays: sub ax,1                
        sbb dx,0                
        cmp ax,0
        jne delays
	cmp dx,0
        jne delays
        pop dx
        pop ax
        ret
;============================set newint7ch sub table
newint7ch: jmp short set
  table dw offset sub1 - offset newint7ch + 200h
        dw offset sub2 - offset newint7ch + 200h
       	dw offset sub3 - offset newint7ch + 200h
       	dw offset sub4 - offset newint7ch + 200h

   set: push bx
        
       	cmp ah,3
       	ja sret
       	mov bl,ah
       	mov bh,0
       	add bx,bx
       	call word ptr cs:[bx+202h]

   sret:pop bx
        iret
;========================Subroutine 
sub1:   push bx
        push cx
        push es

        mov bx,0b800h
        mov es,bx
        mov bx,0
        mov cx,2000
sub1s:  mov byte ptr es:[bx],' '
        add bx,2
       	loop sub1s

       	pop es
       	pop cx
       	pop bx
       	ret
;------------------------
sub2:   push bx
        push cx
       	push es

       	mov bx,0b800h
       	mov es,bx
       	mov bx,1
       	mov cx,2000
sub2s:  and byte ptr es:[bx],11111000b
        or es:[bx],al
       	add bx,2
       	loop sub2s

       	pop es
       	pop cx
       	pop bx
       	ret
;----------------------
sub3:   push bx
        push cx
       	push es

       	mov cl,4
       	shl al,cl
       	mov bx,0b800h
       	mov es,bx
       	mov bx,1
       	mov cx,2000
sub3s:  and byte ptr es:[bx],10001111b
        or es:[bx],al
       	add bx,2
       	loop sub3s

       	pop es
       	pop cx
       	pop bx 
       	ret
;-----------------------
sub4:   push cx
       	push es
       	push ds
       	push si
       	push di

       	mov si,0b800h
       	mov es,si
       	mov ds,si
       	mov si,160
       	mov di,0
        cld
       	mov cx,24
sub4s:  push cx
        mov cx,80
       	rep movsw 
       	pop cx
       	loop sub4s

       	mov cx,80
       	mov si,0
sub4s1: mov byte ptr es:[160*24+si],' '
        add si,2
       	loop sub4s1
       
       	pop di
       	pop si
       	pop ds
       	pop es
       	pop cx
        ret

newint7ch_end: nop

code ends
end start



猜你喜欢

转载自blog.csdn.net/weixin_41944412/article/details/80715166