sort program assembly

Please support our Assembly advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2006
Posts: 1
Reputation: khwan is an unknown quantity at this point 
Solved Threads: 0
khwan khwan is offline Offline
Newbie Poster

sort program assembly

 
0
  #1
Dec 4th, 2006
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 23
Reputation: Day Brown is an unknown quantity at this point 
Solved Threads: 0
Day Brown Day Brown is offline Offline
Newbie Poster

Re: sort program assembly

 
0
  #2
Dec 7th, 2006
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Assembly
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC