hi friends i'm new here
i'm trying to write an assembly program that generate random numbers, shuffle them and sort them in ascinding order

i tried a lot and this is what i did but still there is problem so anybody who can help i would be more thankful

#make_COM#
; COM file is loaded at CS:0100h
ORG 100h

mov ch,3
mov bp,400h
mov [0300h],100h
again:
mov SI,100h ;;Point SI to multiplier.
mov DI,200h
;;Point DI to seed.
lodsw ;;Get low word of multiplier.
mov Bl,Al ;;Save that.
mul word ptr [DI+2] ;;Multiply by high word of seed.
mov Cl,Al ;;Save low word of that for high word of result.
lodsw ;;Get high word of multiplier.
mul word ptr [DI] ;;Multiply by low word of seed.
add Cl,Al ;;Add low word into high word of result.
xchg Al,Bl ;;Get low word of multiplier.
mul word ptr [DI] ;;Multiply by low word of seed.
add Dl,Cl ;;Add other high word components.
;; add constant modulo 2^32.
add Al,1 ;;Constant = 1 (relatively prime to
adc Dl,0 ;; everything).
;; store seed back.
stosw ;;Store low word.
mov [DI],Dl
;;Store high word.
mov [bp],al
inc bp

mov si, [0300h]
mov [si],ah
inc si
mov [0300h],si

inc di
dec ch


cmp ch,0
jg again


mov si,0100h
mov bp,0400h
mov bx,0200h
mov cx,3

loop1: mov al,[si]
mov [bx],al
inc bx
mov al,[bp]
mov [bx],al
inc bp
inc si
inc bx
loop loop1


mov cx,5
dec bx
jmp loop2
loop4:
loop3: dec cx
loop2: mov al,[bx]
dec bx
mov dl,[bx]
cmp cx,0
jz loop5
cmp al,dl
ja loop3
inc bx
mov [bx],dl
dec bx
mov [bx],al
loop loop2
loop5: mov cx,6
add bx,5h
loop loop4
;l:
;jmp loop2
hlt


hope to hear reply soon

How many random numbers? I used the exact number of milliseconds the keyboard was last used as a random input. You could use PING to do pretty much the same.

This article has been dead for over six months. Start a new discussion instead.