# SIC/XE Program to arrange an array of 100 words in ascending order

This System Software program demonstrates an SIC/XE program to arrange 100 words in ascending order and storing the result in the array variable BETA.

### Suppose that ALPHA is an array of 100 words. Write a sequence of instruction for SIC/XE to arrange the 100 words in ascending order and store result in an array BETA of 100 elements.

### Source Code

Line Number | Code | Comments |
---|---|---|

1 | SORT START 0 | |

2 | OUTER LDX INDEX | |

3 | LDS ARR1,X | |

4 | LDX #0 | |

5 | INNER LDT ARR1,X | |

6 | COMPR S,T | |

7 | JLT LOOP | |

8 | JEQ LOOP | |

9 | RMO S,A | |

10 | RMO T,S | |

11 | RMO A,T | |

12 | RMO X,A | |

13 | LDX INDEX | |

14 | STS ARR1,X | |

15 | RMO A,X | |

16 | STT ARR1,X | |

17 | LOOP RMO X,A | |

18 | ADD #3 | |

19 | COMP LENGTH | |

20 | RMO A,X | |

21 | JLT INNER | |

22 | LDA INDEX | |

23 | ADD #3 | |

24 | COMP LENGTH | |

25 | STA INDEX | |

26 | JLT OUTER | |

27 | ARR1 RESW 10 | |

28 | LENGTH WORD 30 | |

29 | INDEX WORD 0 |