'abc', 'hey', 'a', 'heee'Then the sorted output (in increasing order) is the sequence
'a', 'abc', 'heee', 'hey'.There is a sorting procedure called SELECT in the textbook (section 10.3, page 189). However, procedure SELECT sorts an array of numbers. We want to modify SELECT so that it sorts an array of strings.
MAX_LEN EQU 20Your program should work in case we replace ``20'' by any other value. Assume our strings are at most MAX_LEN characters long, and the end of a string is indicated by storing a carriage return (CR or 0Dh). So the actual length of a string is a number between 0 and MAX_LEN. Note that the CR is not counted in the actual length. In addition to strong CR, we also need two other bytes: the first byte stores the number MAX_LEN, and the second byte stores the actual length of the string. So we need to reserve MAX_LEN+3 bytes for each string.
'!' < '&' < '0' < '1' < 'A' < 'Z' < 'a' < 'b' < '{'You may assume only printable ASCII codes are in a string and CR is not in the string. COMP must be general, i.e., it must not assume that the two strings to be compared have length MAX_LEN or that they have the same maximum length. Assume that COMP returns a value of -1 (if less than), 0 (if equal) and +1 (if greater than).
'are', 'at', 'as', 'by', 'but', 'be', '91', 'Johnson', 'ASCII', 'USA', 'New York', 'John', 'a1', 'Number One', '!!!', 'yap@cs.nyu.edu'You must write a procedure called PRINT which outputs the strings in array A. Make sure that you call PRINT before and after sorting in the main program. NOTE: You can adapt a very similar procedure found in p.212 of the textbook (PGM 11_2.asm).
@rem debug batch file echo DEBUGGING HW3 tasm /z /zi hw3 tlink /v hw3 td hw3 echo DONE DEBUGGING HW3REASON: we want to execute db.bat to get quickly into the turbo debugger to examine your sorting program. [3 pts]
'are', 'at, 'zzzz', etc,into the array A, my data segment will look like this:
.data A db MAX_LEN,3,'are',CR,MAX_LEN-3 dup (?) db MAX_LEN,2,'at',CR,MAX_LEN-2 dup (?) db MAX_LEN,4,'zzzz',CR,MAX_LEN-4 dup (?) ... etc
:> mysort > outfilewill put the output of mysort into the file "outfile".
:> mysort | moreand this will pause when the output fills one screenful. You need to type a space for it to continue.