一道汇编题目 X+Y-3->R

用汇编语言实现R<-X+Y-3
其中R·X·Y都是字数组,要求X,Y放在D_SEG段,R放在E_SEG段 

D_SEG segment 
    x dw 
200 , 241 , 308 , 102 , 1247  
    y dw 
20 , 25 , 2530 , 888 , 356  
D_SEG ends 
E_SEG segment 
    r dw 
5  dup( ?
E_SEG ends 
datagroup group D_SEG,E_SEG 
code segment 
    assume cs:code,ds:datagroup 
main proc far 
    mov ax,datagroup 
    mov ds,ax 
    call compute 
    mov ax,4c00h     
    
int  21h 
main endp 
compute proc near 
    mov cx,
5  
    mov si,
0  
next: 
    mov ax,x[si] 
    add ax,y[si] 
    sub ax,
3  
    mov r[si],ax 
    add si,
2  
    loop next 
    mov cx,
5  
    add di,
0  
net: 
    mov bx,r[di] 
    push cx 
    call put 
    call crlf 
    add di,
2  
    pop cx 
    loop net 
    ret 
compute endp 
put proc near 
    mov cx,10000d 
    call output 
    mov cx,1000d 
    call output 
    mov cx,100d 
    call output 
    mov cx,10d 
    call output 
    mov cx,1d 
    call output 
    ret 
put endp 
output proc near 
    mov ax,bx 
    mov dx,
0  
    div cx 
    mov bx,dx 
    mov dl,al 
    add dl,30h 
    mov ah,
2  
    
int  21h 
    ret 
output endp 

crlf proc near 
    mov dl,0ah 
    mov ah,
2  
    
int  21h 
    mov dl,0dh 
    mov ah,
2  
    
int  21h 
    ret 
crlf endp 
code ends 
end main
 

你可能感兴趣的:(一道汇编题目 X+Y-3->R)