Don't like ads? PRO users don't see any ads ;-)
Guest

ExeciN

By: a guest on May 14th, 2012  |  syntax: ASM (NASM)  |  size: 0.56 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. TITLE Array Sum
  2.  
  3. INCLUDE Irvine32.inc
  4.  
  5. .data
  6.     array1 dword 5Fh, 1337h, 3D4Bh, 1ACh
  7.     sum dword ?
  8.                        
  9. .code
  10. main PROC
  11.    
  12.     mov ecx, LENGTHOF array1            ;setting the counter
  13.     mov eax, 0                          ;initializing the register
  14.    
  15.     L1:                                 ;the loop starts here
  16.         add eax, [array1+ecx*4]         ;adding a position of the array to eax
  17.     Loop L1                             ;the loop ends here
  18.    
  19.     add eax, array1                     ;adding the first value of the array
  20.                                         ;    because the the loop ended on ecx=0
  21.     call writehex                       ;displaying the sum
  22.        
  23.     exit
  24. main ENDP
  25. END main