Advertisement
Guest User

siegfrieds ass

a guest
Apr 16th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. TITLE Arrays (Array.asm)
  2. ;Andrew Olsen
  3. INCLUDE Irvine32.inc
  4. .data
  5. array SDWORD ?, ?, ?, ? ;sets up the array
  6. prompt BYTE "Enter in a number ", 0 ;prompt for entering number
  7. sum SDWORD ? ;variable for sum
  8. result BYTE "The sum is ",0 ;message for result
  9. .code
  10. main PROC
  11. mov ebx, array ;moves array to ebx
  12.  
  13. mov edx, OFFSET prompt ;moves offset of prompt to edx
  14. call WriteString ;writes the prompt
  15. call ReadInt ;reads in the integer
  16. mov [array], eax ;moves the read int to the first array spot
  17.  
  18. mov edx, OFFSET prompt
  19. call WriteString
  20. call ReadInt
  21. mov [array+4], eax ;moves the read int to the 2nd array spot
  22.  
  23. mov edx, OFFSET prompt
  24. call WriteString
  25. call ReadInt
  26. mov [array+8], eax ;moves the read int to the 3rd array spot
  27.  
  28. mov edx, OFFSET prompt
  29. call WriteString
  30. call ReadInt
  31. mov [array+12], eax ;moves the read int to the 4th array spot
  32.  
  33. mov eax, [array] ;moves the first value to eax
  34. add eax, [array+4] ;adds the second value to eax
  35. add eax, [array+8] ;adds the 3rd value to eax
  36. add eax, [array+12] ;adds the 4th value to eax
  37. mov sum, eax ;moves eax to sum
  38.  
  39. mov edx, OFFSET result ;moves offset of result to edx
  40. mov eax, sum ;moves sum to eax
  41. call WriteString ;writes result message
  42. call WriteInt ;writes contents of eax
  43.  
  44. exit
  45. main endp
  46. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement