Project question:

1. Input 5 numbers between +5000 to -5000(if attempt to enter number outside this range an error message should be generated and the users must be allowed to try again. The program must tell the user the number(1 through 5) of the current entry(i.e. Input #1:, Input #2:, etc.)

. Display the 5 number sorted in ascending order and right hand justified

3. Display the sum of the five numbers

I am having problem writing the codes to sort them. so far what i have written outputs the sum and the five numbers input. Is there anyway i can sort them without using insertion sort?

Your response is greatly appreciated

INCLUDE PCMAC.INC

.MODEL SMALL

.STACK 100h

.DATA

Msg1 DB 'Enter(number bwt. 5000 and -5000) as input #', '$'

Msg2 DB 'Number out of range, enter a new one', 13, 10, '$'

Msg3 DB 'Sum of five inputs are ', '$'

N EQU 5

count DW 1

sum Dw 0

SaveSum DW ?

.CODE

EXTRN GetDec : NEAR, PutDec : NEAR

lab5 PROC

mov ax, @data

mov ds, ax

mov cx, N

jcxz laker2

loop1:

_PutStr Msg1 ; display Msg1

mov ax, count

call PutDec

inc count

_PutCh 13, 10

call GetDec

cmp ax, 5000 ; if (number <= 5000) and...

jnle laker1

cmp ax, -5000 ; (number >= -5000) then...

jnge laker1

jmp laker2

laker1:

_PutStr Msg2 ; display Msg2

call GetDec ; get number

laker2:

add ax, sum

mov sum, ax

loop loop1

mov ax, sum

mov SaveSum, ax

_PutStr Msg3

mov ax, SaveSum

call PutDec

_Exit 0

lab5 ENDP

END lab5