youngyou4 0 Newbie Poster
SORT     STM   0,15,SSAVE        Store registers to SSAVE
         LM    2,3,0(1)          Load in parameters
         LA    3,0(3)            Pointer to end of table
         LA    4,0(2)            Pointer to first table entry 
DO1      CR    4,3               Compare table entry to end of table 
         BH    ENDDO1            Branch if
         L     6,0(4)            Value of Low
         LA    5,4(4)            Pointer to Index
DO2      CR    5,3               Compare next table entry to EOT
         BH    ENDDO2            Branch if
         L     7,0(0,5)          Value of the index L     
CHECK    CR    6,7               Compare low with next entry     
         BH    ENDCHECK          Branch if
         LR    6,7               Load Low's value with Index Value
         LA    4,0(5)            Load Low's address with index address
ENDCHECK LA    5,4(5)            Move next index pointer to next entry
*                                address
         B     DO2
ENDDO2   L     8,0(2)            Load temp with value of BEGIN
         ST    8,0(7)            Load LOW into BEGIN
         ST    4,0(2)            Load BEGIN into LOW
         LA    7,4(7)            Increment Begining            
         B     DO1
ENDDO1   LM    0,15,SSAVE        Restore Register        
         BR    10                Return to main
         LTORG                   
TEMP     DS    CL12
SSAVE    DS    16F

The Program is abending at L 7,0(0,5) and it's not sorting correctly.
I'm not sure exactly what I'm doing wrong. Is it in an infinite loop? I'm a little stuck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.