8086汇编 中断例程

来源:互联网 发布:c语言内嵌汇编 64位 编辑:程序博客网 时间:2024/06/05 13:23

内中段

  

1,0号中断  用显示代替除法中断


assume cs:code


 code segment

 

start:   首先加载内存,将你将要编写的代码

           mov ax,cs     d0还有其他都在start段中  是cs指向的代码段

           mov ds,ax

           mov si,offset d0      ;ds:si 源地址

           mov ax,0

           mov es,ax

           mov di,200               ;es:di

           mov cx,offset d0end-offset d0

           cld

           rep movsb


         mov ax,0    ;设置中断向量表

       mov es,ax

       mov word ptr es:[0*4],200h

      mov word ptr es:【0*4+2】,0

           mov ax,4c00h

           int 21h

do0:

jmp short  d0start

   db "sdjvkjsdvnk"


 

d0start:

          mov  ax,cs

          mov ds,ax

          mov si,202                       ;  ds:si

          mov ax,0b800h

          mov es,ax

         mov di,12*160+36*2   ;es:di

          mov cx,21

  s:

      mov al,[si]

      mov es:[di],al

      inc si

      add di,1

    mov al,02h   颜色

    mov es:[di],al

   add di,1

      loop s

          mov ax,4c00h

           int 21h

d0end:

nop

 end start

2,,,,

安装中断7ch的中断例程,实现求一word型数据的平方

assume cs:code
  code segment
  start:
      mov ax,3456
      int 7ch   ;调用7ch中断例程,计算ax数据的平方
      add ax,ax
      adc dx,dx
      mov ax,4c00h
      int 21h
  code ends
    end start
    
    
assume cs:code

code segment
 start:
     mov ax,cs
     mov ds,ax
     mov si,offset sqr
     mov ax,0
     mov es,ax
     mov di,200h
     mov cx,offset sqrend - offset sqr
     cld
     rep movsb
    
    
    
     mov ax,0
     mov cs,ax
     mov word ptr cs:[7ch*4],200h
     mov word ptr cs:[7ch*4+2],0
     
     mov ax,4c00h
     int 21h
  sqr:
     mul ax
     iret
rqrend: nop

  code ends
 end start

3,安装中断7ch的中断例程。将一个全是字母,以0结尾的字符串改为大写字母

assume cs:code  ds:data
data segment
    db 'conversation',0
    
data ends
    
 code segment
   start:
   mov ax,data
   mov ds,ax
   mov si,0
   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,ofset cheng
  mov ax,0
  mov es,ax
  mov di,200h
  mov cx,offset chengend -offset cheng
  cld
  rep movsb
   
  mov ax,0
  mov cs,ax
  mov word ptr cs:[7ch*4],200h
  mov word ptr cs:[7ch*4+2],0
 
  mov ax,4c00h
  int 21h
 
cheng:
  push cx
  push si
  change:
    mov cl,[si]
    mov ch,0
    jcxz ok
    and byte ptr [si],11011111b
    inc si
    jmp short change
    ok:
    pop si
    pop cx
    iret
    
chengend:nop
    
    code ends
    end start

5,用7ch中断完成loop  s功能,规定cx存放循环的次数,bx是到s的位移

zai 屏幕中间显示80个!


   assume cs:code

 code segment

 start:

   mov ax,0b800h

  mov es, ax

  mov di,160*12+36*2

  mov bx, offset s - offset s0

  mov cx,80

 s:

   mov word ptr es:[di],'!'

   add di,2

   int 7ch

s0:

  nop

code ends

end start



assume cs:code

code segment

start:

......

.....

s1:

   push bp

   mov bp,sp

  dec cx

  jcxz s2

 add  [bp+2],bx

s2: pop bp

      iret