System Software – SIC/XE Program to arrange an array of 100 words in ascending order

Problem Statement

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.

Solution

Line NumberCodeComments
1SORT START 0 
2OUTER LDX INDEX 
3LDS ARR1,X 
4LDX #0 
5INNER LDT ARR1,X 
6COMPR S,T 
7JLT LOOP 
8JEQ LOOP 
9RMO S,A 
10RMO T,S 
11RMO A,T 
12RMO X,A 
13LDX INDEX 
14STS ARR1,X 
15RMO A,X 
16STT ARR1,X 
17LOOP RMO X,A 
18ADD #3 
19COMP LENGTH 
20RMO A,X 
21JLT INNER 
22LDA INDEX 
23ADD #3 
24COMP LENGTH 
25STA INDEX 
26JLT OUTER 
27ARR1 RESW 10 
28LENGTH WORD 30 
29INDEX WORD 0