ArraySum

  1. Include Irvine32.inc
  2. .data
  3. array dword 11, 22, 44, 5
  4. theSum dword ?
  5. .code
  6. main proc
  7.     mov esi, offset array
  8.     mov ecx, lengthof array
  9.     call SumInt
  10.     mov theSum, eax
  11.     call writedec
  12. main endp
  13. ;------------------
  14. SumInt proc
  15. push esi
  16. push ecx
  17. mov eax, 0
  18. L1:
  19.     add eax, [esi]
  20.     add esi, type dword
  21.     loop L1
  22.     pop esi
  23.     pop ecx
  24.     ret
  25. SumInt endp
  26. end main
11 + 22 + 44 + 5 = 82

留言

這個網誌中的熱門文章

Codeforces --- string task

Uva 674 ---- coin change

codeforces 271A --- beautiful year