How EUG Disks Work

By Richard Dimond

Originally published in EUG #40

Having read Robert Sprowson's notes on word wrapping and having rewritten the assembler for the new coding - now CODE8 - I thought I would explain how the new coding runs the disks.


The source code for this m/code utility to display text is on this disk in the U directory. I have added some REM lines to the listing in the hope they will help you to understand the code. All line numbers in this article refer to the assembler listing.

There are two calls made to the coding from the menu 'clear' and 'print'. These are at &900 and &903 but jump to the start of the routines.

clear (line 300)

This routine clears the memory from HIMEM to &4000 - the start of a Mode 3 screen. It first loads the address of HIMEM (at &06, &07) into &70, &71 and the loop stores a zero into each byte of memory. This is necessary as the coding checks for zero at the end of the file.

print (line 410)

The flags for printing bold and italic characters are first set to zero.

Then, osbyte with A=&87 (*FX 135) is used to check the Mode number (line 430) and the modeflag set for the Mode selected.

Line 470 checks if the printer is set and sets style for use in the sub-routines 'bd' or 'it' if this is set.

Line 530 jumps to the 40 column routine at line 690 if the moeflag is set to &FF.

If the skip flag is set to &FF, line 630 will print the linefeeds to skip the perforations when using the printer.

When either highlight is set, lines 640 and 650 set the corresponding flag for the font change and reset it the next time to return to normal print. The routine 'bd' or 'it' is called while one of these flags is set.

The line 680 ends the 'prt' routine with a JMP in 80 column printing mode and an RTS for 40 column - this was necessary to correct the trouble with the perforation skip routine we had earlier.

40 Column Printing

The routine starts at line 690 and leading spaces are skipped by the loop at line 710. The comparison at line 700 checks for the number of characters printed and, if there are no leading spaces, it will remain at the value of 39. The value is increased in line 710 for each space found.

The routine 'test' (line 800) is called if a CR character is found. This checks if a CR is needed and calls 'chkchr' at line 1110. This sets the carry flag if one of the five special characters if found and this then branches in the test routine for printing the title and underline correctly.

I found that titles were printed with an initial space and have corrected this by amending line 900. This checks the print position held in address &318 and, if this is zero, skips the printing of a space but a space is printed to separate words.

If a line is completed (when the comparison at line 770 is equal), the routine 'next' (line 960) is called.

If one of the five characters is found then a jump is made to 'skipchr' in line 1080. This increases the index to point to the start of the next line. The value of the index Y is added to 'addr' in routine 'incaddr' (line 1040) and a jump made to 'line' for printing the next line. This ensures that only 40 of these characters are printed.

If none of these characters are found, chkchr2 is called and this sets the carry flag if neither a letter nor number is found, the character printed and osnewl is called at line 1020 and 'addr' increased as above.

If the carry flag is not set, the word is not completed, and the routine 'delete' is called and the characters deleted until a character other than a letter or number is found. The index is then pointing to this character and this is then printed and the word printed on the next line.

Line 1250 resets the carry flag if a ' or / is found to avoid splitting words containing these characters.

The routines 'bd' and 'it' provide the fonts by getting the definition with routine 'getdef' (line 1840) and altering the bytes in 'block'. The character (CHR$255) is then made up using VDU23 in routine 'makchr' to make the coding suitable for the Master. For the printer, the necessary codes are set in the string variables bold, ital and normal.

The "PRINT" Program

This program is easily followed to show all text files on screen with a press of the O button on any menu. It runs normally if Z% is FALSE but if TRUE the procedure PROCtext also dumps the individual files to a printer.

Notes on the procedures follow:


T% is a flag to allow printing of the messages when this is FALSE for printing to screen. VDU14 sets paged mode and PROCdirs is called.


T% is TRUE to skip the messages and VDU15 cancels paged mode. If Z% is TRUE PROCtext is called for printing individual files and if FALSE PROCdirs is called for printing all text files.


This changes the Directories in turn (if a directory is not used, it may be REMed out). The routine 'readdir' is called to read and print text files. The program returns to the root directory at the end for return to the menu.


This uses 'OSGBPB' with A=8 to read the filenames in the selected directory. Each filename is read and checked if the first character is a + indicating a text file and if so PROCldfile is called to put the filename into the print routine.


This assembles the variable fn$ for loadong into the 'print' routine from the filename buffer 'fname' when read from the directories.


The Mode is set to MODE6 to avoid the screen flicker while loading the files and 'clear' is called to clear the memory.

The files are loaded with *LOAD fn$ 2600. The mode is then set to the value of m% and, if T% is TRUE, the file is sent to the printer. VDU15,2 resets page mode and turns the printer on or sets page mode and prints the cue to Scroll if T% is FALSE for printing to screen.


This routine is called when Z% is TRUE when individual files are to be printed and are selected from the menus.

The string variables f$, P$ and S$ are loaded from the stack and the Mode value m% is set to 6 if M% is TRUE or 3 if M% is FALSE.

The rest of the program should be fairly easily followed and I hope I have explained these sufficiently clearly.

Notes For DFS Users

There are sometimes modifications to the "PRINT" program if there are text files on the flipside (DRIVE 2) of the EUG disk. This simply means that commands such as *DRIVE 2 and *DRIVE 0 have to be inserted around the PROCdirs procedures where appropriate.

Richard Dimond, EUG #40