DMG

Sabiranje niza

DMG
Mar 16th, 2012
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4.     a db 1,2,1,2,1,2
  5.     n dw 6
  6.     suma db ?
  7.    
  8.    
  9.     pkey db "press any key...$"
  10. ends
  11.  
  12. stack segment
  13.     dw   128  dup(0)
  14. ends
  15.  
  16. code segment
  17. start:
  18. ; set segment registers:
  19.     mov ax, data
  20.     mov ds, ax
  21.     mov es, ax
  22.  
  23.     mov dl, 0
  24.     mov si, 0
  25.    
  26.    
  27.     for:
  28.     cmp si, n
  29.     jl saberi
  30.     jmp kraj
  31.    
  32.     saberi:
  33.     add dl, a[si]
  34.     add si, 1
  35.     jmp for
  36.    
  37.     kraj:
  38.     mov suma, dl
  39.            
  40.     lea dx, pkey
  41.     mov ah, 9
  42.     int 21h        ; output string at ds:dx
  43.    
  44.     ; wait for any key....    
  45.     mov ah, 1
  46.     int 21h
  47.    
  48.     mov ax, 4c00h ; exit to operating system.
  49.     int 21h    
  50. ends
  51.  
  52. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment