实训汇编语言设计——找出两个数组中相同的整数

找出A,B中相同的整数,存入C中

datarea segment
 a dw 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
 b dw 2,4,6,8,10,20,21,22,23,24,25,26,27,28,29,1,3,5,7,9
 c1 dw 15 dup(0)
datarea ends
prognam segment
 main proc far
 assume ds:datarea, cs:prognam
start:
;set up stack to retuan
    push ds
    sub ax,ax
    push ax
;set DS register to current segment
    mov ax,datarea
    mov ds,ax
    mov es,ax

;main part of the prognam goes here
    cld                        
 lea di,b
 mov cx,15                   
 mov si,0
 mov bx,0
next:
    push di                     
    push cx                      
    mov ax,a[si]
    mov cx,20                    
    repnz scasw                                       
    je setc                       
    jmp loop1
setc:
   
    mov c1[bx],ax                                   
    add bx,2
loop1:
    add si,2                            
    pop cx
    pop di
   loop next
 
    ret  
 main endp
  prognam ends
       end start
     
   
 
     

posted @ 2007-12-21 14:21  Java天堂  阅读(406)  评论(0)    收藏  举报