Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Assembly Language Programming (ALP) Forum (http://www.go4expert.com/forums/assembly-language-programming-forum/)
-   -   assembly pgm-selection sort (http://www.go4expert.com/forums/assembly-pgm-selection-sort-t19833/)

nits 20Oct2009 23:42

assembly pgm-selection sort
 
please tell me how 2 write an assembly program to perform selection sorting??

xpi0t0s 21Oct2009 03:18

Re: assembly pgm-selection sort
 
Where are you stuck? What code have you got so far?

nits 21Oct2009 23:44

Re: assembly pgm-selection sort
 
LXI H,2500H
MOV C,M
L3: DCR C
JZ L4
MOV B,C
LXI H,2501
L2: MOV A,M
INX H
CMP M
JNC L1
MOV D,M
MOV M,A
DCX H
MOV M,D
INX H
L1: DCR B
JNZ L2
JMP L3
L4:RST 1





Is this wrong????? the program is going on an infinite loop

xpi0t0s 22Oct2009 05:20

Re: assembly pgm-selection sort
 
Quote:

Originally Posted by nits (Post 59163)
Is this wrong????? the program is going on an infinite loop

Then yes, I would say it is wrong.

Are you sure it's an infinite loop? If L4 is the exit point (what does RST 1 do?) then the condition for reaching that point is where C is decremented to zero, and since there is nothing that otherwise modifies C then this should eventually happen.

It would help if the code were commented. Then I could understand what you're trying to do at each point.


All times are GMT +5.5. The time now is 06:06.