[汇编] 2数相加极简单版

>_<:低位相加:

 1 ; multi-segment executable file template.
 2 
 3 data segment
 4     datax   dw      0148H,2316H
 5     datay   dw      0237H,4052H  
 6 ends
 7 
 8 stack segment
 9     dw   128  dup(0)
10 ends
11 
12 code segment
13 start:
14 ; set segment registers: 
15     mov ax,data
16     mov ds,ax
17     mov es,ax
18     
19     ; add your code here
20     mov ax, datax
21     add datay, ax     
22     ; wait for any key....  
23     mov dl, 03H
24     mov ah, 2
25     int 21h  
26       
27     mov dl, 7FH
28     mov ah, 2
29     int 21h   
30     mov ah, 1
31     int 21h
32     
33     mov ax, 4c00h ; exit to operating system.
34     int 21h    
35 ends
36 
37 end start ; set entry point and stop the assembler.

 

>_<:带进位2位相加

; multi-segment executable file template.

data segment
    datax   dw      0148H,2316H
    datay   dw      0237H,4052H  
ends

stack segment
    dw   128  dup(0)
ends

code segment
start:
; set segment registers: 
    mov ax,data
    mov ds,ax
    mov es,ax
    
    ; add your code here
    mov ax, datax
    add datay, ax    
    mov ax,datax+2 
    adc datay+2,ax 
    ; wait for any key....  
    mov dl, 03H
    mov ah, 2
    int 21h  
      
    mov dl, 7FH
    mov ah, 2
    int 21h   
    mov ah, 1
    int 21h
    
    mov ax, 4c00h ; exit to operating system.
    int 21h    
ends

end start ; set entry point and stop the assembler.

 

 

posted @ 2014-04-03 14:53  beautifulzzzz  阅读(539)  评论(0编辑  收藏  举报