FALL 2000 CSCI 2370 10/27/2000

ASSIGNMENTS

TEXT EDITOR



Assignment 2 due: 11/3

Write the macros GETCHAR, PUTCHAR, GOTOLC, PUTS, SCRLUP, and SCRLDN and a main program that will test these macros for correct operation. Run the program as many times as necessary to insure the correctness of the macros. (One of the main uses for GETCHAR in this assignment will be to suspend the program until a key is pressed so that you can see the cursor move from place to place. But also test, at least once, that the character is placed in the AL register.)

The grade for each lab includes a portion (15%) on programming style and a portion (20%) on how well the program, subprograms and macros were tested. Turn in a listing of the ASM file and a copy of your EXE file on a 3.5" diskette. You will want to include a few PrintScreens to show that your tests worked.



DESCRIPTION OF THE MACROS

GETCHAR the macro that reads a character from the keyboard. The character is stored in AL.

PUTCHAR the macro that displays a character to the screen. The character should be a parameter to the macro.

GOTOLC the macro that displays the cursor at the line given by the first parameter (0-24) and at the column given by the second parameter (0-79). So GOTOLC 5,9 would display the cursor at line 5, column 9 (sixth line, tenth column).

PUTS the macro that move the cursor to the line given by the first parameter and the column given by the second parameter and then displays the string given by the third parameter. The string is in the data segment, and all the characters before the be terminating '$' are displayed.

SCRLUP the macro to scroll part of the screen up one line leaving a blank line at the bottom. The first parameter gives the starting line and the second the ending line for the scroll.

SCRLDN the macro to scroll part of the screen down one line leaving a blank line at the top. The first parameter gives the starting line and the second the ending line for the scroll.



SCREEN AND KEYBOARD HANDLING



The screen is 25 lines long and 80 characters wide. We will write the values and headings to the screen using DOS interrupts.

To clear the screen:

MOV AX,0600H

MOV BH,07

MOV CX,0

MOV DX,184FH

INT 10H



To display the cursor at position line n, column m:

MOV AH,02

MOV BH,00

MOV DX,nm n in DH and m in DL

INT 10H



To put a series of characters on the screen starting at the cursor position, the series of characters must be in the data segment at location 'STRING' and the series must end with a $. The following statements will display the characters on the screen:

MOV AH,09

LEA DX,string

INT 21H



To read a character from the keyboard that is not echoed to the screen (the character is placed in AL):

MOV AH,08

INT 21H



To write a character in DL onto the screen at the cursor location:

MOV AH,02

INT 21H



To move the screen up one line from line j to line k (between columns c and d), i.e. line j disappears, line j+1 is now at line j,... and a blank line appears at line k:

MOV AX,0601H

MOV BH,07H

MOV CX,jcH

MOV DX,kdH

INT 10H



To move the screen down one line from line j to line k (between columns c and d), i.e. line k disappears, line k-1 is now at line k,... and a blank line appears at line j:

MOV AX,0701H

MOV BH,07H

MOV CX,jcH

MOV DX,kdH

INT 10H




FALL 2000 CSCI 2370 11/3/2000

ASSIGNMENTS

TEXT EDITOR





Assignment 3 due: 11/10

Write and run the subprograms INITSCR and DSPTEXT and a test main program that will test these subprograms for correct operation. You should use the RDFIL subprogram that will be given to you so you can test.

Assignment 4 due: 11/17

Write and run the subprogram DSPSTAT, the macro BY2DSTR, and a test main program that will test this subprogram and macro for correct operation.

Assignment 5 due: 11/27

Write and run the cursor control subprograms CURUP, CURDN, CURRT, and CURLT and the first version of the MAIN program that will be used to test these subprograms for correct operation.

Assignment 6 due: 12/4

Write and run the subprograms INSCHAR, DELCHAR, and WRTFIL and complete the main program to implement the text editor as designed. The subprogram RETURN will be given to you.





THE INTERNAL STORAGE REPRESENTATION FOR THE TEXT



The text is stored in ASCII form in a series of memory locations labeled TEXT. TEXT is 100 lines long, and each line contains 80 characters followed by a $. The lines are numbered 0 to 99 and the columns are numbered 0 to 79. The text will be displayed on the screen on lines 0 to 23. Line 24 will be used to display the status of the cursor and the editor.

Other global data values

--------------------------------------

CSL cursor screen line number

CC cursor screen column number

CTL cursor text line number

TEXTPOS the offset in TEXT where the cursor

is located, corresponds to CTL & CC

LINES number of lines used in the text

MAXLINES a constant equated to the maximum lines

available in TEXT



THE TEXT EDITOR



The text editor will allow the user to input text into memory and then edit the text by inserting and deleting characters. The cursor can be used to locate the position for insertion and deletion. The text can be written to a file.



HEX

KEYS VALUE ACTION

---- ----- ---------------------------------------------------

DEL 00,53 deletes the character at the cursor position, and moves the text on that line left one position. The cursor remains at its original location.



ENTER 0D The character at the cursor position and the rest of that line become the new next line. The cursor is now at the beginning of the new line and the old line ends in blanks.



00,48 moves the cursor up one line in the text and on the screen, if it is not already at the top line. If the cursor is on the top line of the screen and there is a new line of text to display, the new line appears at the top of the screen and the rest of the text on the screen scrolls down one line.



00,50 moves the cursor down one line in the text and on the screen, if it is not already at the bottom line. Similar action to cursor up movement is taken if the cursor is at the bottom of the screen.



00,4D moves the cursor to the right one position in the text and on the screen. If the cursor is already at the right edge of screen, it moves to the beginning of the next line of text.



00,4B moves the cursor to the left one position in the text and on the screen. If the cursor is already at the left edge of screen, it moves to the end of the previous line of text.



normal 20.7E inserts the character into the text at the cursor

chars position. The rest of the line moves to the right one position and the cursor also moves to the right.



CTRL-W 17 writes the entered text into a file using the filename provided by the user.



CTRL-R 12 reads a file and places the text into the array, The filename is provided by the user.



CTRL-Q 11 quits the editor.



GENERAL INFORMATION



Names of subprograms and macros

-------------------------------

MAIN the main program that calls the other subprograms depending on the key that has been pressed.



INITSCR the subprogram that initializes the screen and the global variables for entry of text.



DSPTEXT the subprogram used if a file is read to display the first 24 lines in the TEXT array and initialize the global variables. If the file has less than 24 lines, than only those lines are displayed.



DSPSTAT the subprogram that displays the status line on line 24 of the screen and then moves the cursor back to where it is supposed to be in the text. See the sample screen for details.



BY2DSTR the macro that converts a byte direct binary number into a three digit decimal character representation. Leading zeros are made into spaces.



CURUP the subprograms to handle the movements of the

CURDN cursor. See the explanations of and above.

CURRT

CURLT



INSCHAR the subprogram to insert a character into the text. It is called when a normal character is pressed. See the explanation above on normal characters (20..7E). On entry the character is in AL.



DELCHAR the subprogram to delete a character from the text. See the DEL explanation above.



RETURN the subprogram to insert a carriage return into the text. See the RETURN explanation above. If no lines are available in the text area, nothing should be done.



WRTFIL the subprogram to take the text and write it to a file. The filename is inputed by the user. Blanks at the end of the line are replaced by a carriage return and line feed.



RDFIL the subprogram to read a text file into the TEXT array and then display the first part of it on the screen.



SAMPLE SCREEN