Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TITLE Arrays (Array.asm)
- ;Andrew Olsen
- INCLUDE Irvine32.inc
- .data
- array SDWORD ?, ?, ?, ? ;sets up the array
- prompt BYTE "Enter in a number ", 0 ;prompt for entering number
- sum SDWORD ? ;variable for sum
- result BYTE "The sum is ",0 ;message for result
- .code
- main PROC
- mov ebx, array ;moves array to ebx
- mov edx, OFFSET prompt ;moves offset of prompt to edx
- call WriteString ;writes the prompt
- call ReadInt ;reads in the integer
- mov [array], eax ;moves the read int to the first array spot
- mov edx, OFFSET prompt
- call WriteString
- call ReadInt
- mov [array+4], eax ;moves the read int to the 2nd array spot
- mov edx, OFFSET prompt
- call WriteString
- call ReadInt
- mov [array+8], eax ;moves the read int to the 3rd array spot
- mov edx, OFFSET prompt
- call WriteString
- call ReadInt
- mov [array+12], eax ;moves the read int to the 4th array spot
- mov eax, [array] ;moves the first value to eax
- add eax, [array+4] ;adds the second value to eax
- add eax, [array+8] ;adds the 3rd value to eax
- add eax, [array+12] ;adds the 4th value to eax
- mov sum, eax ;moves eax to sum
- mov edx, OFFSET result ;moves offset of result to edx
- mov eax, sum ;moves sum to eax
- call WriteString ;writes result message
- call WriteInt ;writes contents of eax
- exit
- main endp
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement