Advertisement
nguyenvanquan7826

sumTwoNumber.asm

Sep 20th, 2013
1,717
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. .model small
  2. .stack 100
  3. .data
  4.     inputA db 'Nhap so A = $'
  5.     inputB db 'Nhap so B = $'
  6.     outputResult db 'Tong A + B = $'  
  7.     CLRF db 13, 10, '$'
  8. .code
  9.     main proc
  10.     mov ax, @data
  11.     mov ds, ax
  12.              
  13.     mov ah, 9         ; hien thi "Nhap so A = "
  14.     lea dx, inputA
  15.     int 21h
  16.    
  17.     call inputDec     ; goi CTC nhap so thu nhat he 10
  18.     push ax           ; luu ax da nhap lai
  19.     call nextLine     ; xuong dong
  20.    
  21.     mov ah, 9         ; lam tuong tu voi so thu hai
  22.     lea dx, inputB
  23.     int 21h
  24.    
  25.     call inputDec
  26.     mov bl, al
  27.     call nextLine              
  28.    
  29.     pop ax            ; goi ax tu Stack ra
  30.     call sum          ; goi ham tinh tong 2 so (trong ax va bx)
  31.     push ax           ; luu ax lai
  32.                      
  33.     mov ah, 9         ; hien thi KQ
  34.     lea dx, outputResult
  35.     int 21h
  36.    
  37.     pop ax
  38.     call outputDec    ; goi CTC hien thi KQ
  39.    
  40.     mov ah, 4ch
  41.     int 21h
  42.    
  43.    
  44.     main endp
  45.    
  46.     sum proc          ; CTC con tinh tong 2 so
  47.         add ax, bx
  48.         ret
  49.     sum endp
  50.                                                            
  51.     nextLine proc     ; CTC xuong dong
  52.         mov ah, 9
  53.         lea dx, CLRF
  54.         int 21h
  55.         ret
  56.     nextLine endp
  57.    
  58.     include include\inputDecProc.asm     ; tep chua CTC nhap so he 10
  59.     include include\outputDecProc.asm    ; tep chua CTC hien thi so he 10
  60. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement