assembly pgm-selection sort

Discussion in 'Assembly Language Programming (ALP) Forum' started by nits, Oct 20, 2009.

  1. nits

    nits New Member

    Joined:
    Oct 20, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    please tell me how 2 write an assembly program to perform selection sorting??
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    Where are you stuck? What code have you got so far?
     
  3. nits

    nits New Member

    Joined:
    Oct 20, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,009
    Likes Received:
    203
    Trophy Points:
    63
    Occupation:
    Senior Support Engineer
    Location:
    England
    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.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice