title Number Addition										(add.asm)

; Dani Horowitz
; CSC111 x86 Assembly Programming

; This program adds integers a user inputs

INCLUDE Irvine32.inc

;--------------------------------------------------
.stack			; begin stack segment

;--------------------------------------------------
.data			; begin data segment

	sum			dword	0
	counter		dword	0
	prompt		byte	"Enter a value: (0 to stop) ", 0
	result		byte	"The sum of ", 0
	count		byte	" numbers is ", 0
	
;--------------------------------------------------
.code			; begin code segment

;--------------------------------------------------


;--------------------------------------------------
prompt_user PROC
;
; Take a break! Pauses screen
;--------------------------------------------------

	mov		edx, OFFSET prompt		; prompt user to enter values
	call	WriteString
	call	Crlf

GetValue:

	call	ReadInt					; read integer from keyboard
	jo		Overflow				; if ReadInt set overflow flag, jump to Overflow

	add		sum, eax				; add entered value to accumulator sum
	jo		Overflow				; if addition set overflow flag, jump to Overflow

	cmp		eax, 0					; did user enter 0?
	je		Done					;   if yes, goto Done
	
	inc		counter					; increment counter
	jmp		GetValue				; loop

Overflow:

	mov		eax, 0
	mov		sum, 0
	
Done:	
	
	ret
;--------------------------------------------------
prompt_user ENDP
;--------------------------------------------------

;--------------------------------------------------
print_sum PROC
;
; Take a break! Pauses screen
;--------------------------------------------------

	mov		edx, OFFSET result	; prints "The sum of "
	call	WriteString
	
	mov		eax, counter		; prints count of #s entered
	call	WriteDec
	
	mov		edx, OFFSET count	; prints " numbers is "
	call	WriteString	
	
	mov		eax, sum			; prints sum
	call	WriteDec
	call	Crlf

	ret
;--------------------------------------------------
print_sum ENDP
;--------------------------------------------------

;--------------------------------------------------
main proc
;--------------------------------------------------
	call	Clrscr			; clear screen
	call	prompt_user		; get integers
	call	print_sum		; print their sum
	exit
	
main  endp
end main
;--------------------------------------------------

While pursuing a Computer Science degree, I founded DaniWeb.com, an online community for developers and IT professionals. I coded the backend platform from the ground up and I also do all of the advertising sales and SEO. I'm a super-geeky programmer with a passion for Internet marketing.

I need to write a program that reads 5 integer exam scores from the user and take the best 3 scores' average. I got an error I could not find the best 3 scores between 5 of them. Can yo help me to write that?

You should enter your five integers by looping and storing in an array, then summing the array.

In your code you don't need the compare as the addition will set the zero flag if the result is zero!

add  sum, eax	; add entered value to accumulator sum	
   jo   Overflow      ; if addition set overflow flag, jump to Overflow
;;;   cmp eax, 0     ; did user enter 0?	
   je   Done           ;   if yes, goto Done
The article starter has earned a lot of community kudos, and such articles offer a bounty for quality replies.