SETXXBD - Setting the Printer Baud Rate Automatically. Paul Burgess. It's often convenient to drive a printer via the serial port, perhaps because you already have a serial printer, or, like me, have the parallel port tied up with something else. Very often, the printer will require a data rate which is not the default (9600 for the Einstein) and it can be annoying to have to enter MOS after every 'Ctrl-Break'. To deal with this, I wrote SETXXBD, and set up the DOS to execute it automatically after every cold boot. The program shows the use of the Einstein's MOS calls inside a program, too. This version was assembled using HiSoft's excellent 'Devpac' assembly language system, but it can be entered by hand or with the Kuma 'Zen' assembler. Any of the standard baud rates may be set by changing the value loaded into the L register according to the table in the Einstein Mos/Dos manual. You should modify the name to indicate what baudrate is used: the example here is SET48BD for 4800 baud. Firstly, EQU statements are used to define labels for the MOS calls and for useful things like carriage return, and so on. This is just to make the program easier to read after I have forgotten what it was for! The ORG statement starts the program at address 100 Hex., this is the standard start address for CP/M and of course XTAL DOS programs. It is usually wise to save the incoming stack pointer from the DOS, and establish a local stack for the program: this is done by the next two statements and the DEFS (Define Storage) statement at the end of the program. Now we get round to the proper job. We'll use the BAUD Mos call ("Mcal") which is the equivalent of the "b" command in the MOS. We need to supply the code for receive and transmit baud rate in the L register of the Z80 and set the DE register to 0 to ensure the data format is not changed. Then, we call the routine by executing a RST 8 (Restart 8) followed by the code for "b", which happens to be 81 Hex. That's all that is needed to do the job, but we should print a short message so the user knows what is going on. The "ZPRM" Mcal is used for this: again we do a 'RST 8' fol- lowed by the code, which is CF Hex. We then supply the prompt message, and terminate it with a carriage return and a line feed. The 80H is added to the line feed in order to tell the ZPRM routine to stop printing. Finally, we restore the stack pointer to its old value, and do a RETurn to the DOS. Having assembled the program, or entered it in hexadecimal using the 'M' command in MOS and then 'SAVE 1 SET48BD.COM' all that's needed is to load the name of the program into the command buffer in the DOS. This is done by reading the system into memory, altering the apropriate locations and re-writing the modified system to disc. ALWAYS try this on a blank disc first. Also, ensure that SETXXBD.COM is present on the system disc and any other you intend to use in drive 0. Enter Mos and modify the system with >R 1000 3800 (System in memory from 1000H) >M 1208 (Modify command buffer) 1208 00 (Current contents shown) 1208 07 (You enter this) 1209 53 45 54 34 38 42 44 (Enter 'SET48BD' in Ascii) 1210 00 (Now enter full stop) >W 1000 3800 (Re-write the system to disc) >Y (Back to the DOS) - If all is well the system will boot and execute SET48BD (or whatever your version is called). Note that the comments in brackets above are not supp- osed to be entered! You may also be wondering about other MOS calls. Some of these were dealt with in the last edition of the Tatung Einstein User magazine. I hope to expand on the theme in future issues of EUGUK, and also take a look at the DOS calls, which are in the main compatible with CP/M. HiSoft GEN80 Assembler 27 Mar 85 Page: 1 Pass 1 errors: 00 0100 1 ;********************************************* 0100 2 ; SETXXBD - SET EINSTEIN BAUDRATE PB 860103 * 0100 3 ; Can put this on system disc for autoboot. * 0100 4 ;********************************************* 0100 5 ; 0100 6 ; 0081 7 BAUD EQU 81H ; SET BAUDRATE CALL 00CF 8 ZPRM EQU 0CFH ; PRINT MESSAGE CALL 000D 9 CR EQU 0DH ; CARRIAGE RETURN 000A 10 LF EQU 0AH ; LINE FEED 0100 11 ; 0100 12 ; 0100 13 ORG 100H ; CP/M & DOS PROGRAMS START. 0100 14 ; 0100 ED733001 15 LD (STAK),SP ; SAVE INCOMING STACK POINTER 0104 314401 16 LD SP,STAK+20 ; AND SET UP OUR OWN 0107 17 ; 0107 217700 18 SETBD LD HL,0077H ; 4800BD TRANSMIT/RECEIVE RATE 010A 110000 19 LD DE,0 ; NO COMMAND CHANGE 010D CF 20 RST 8 ; CALL THE MOS 010E 81 21 DEFB BAUD ; BAUD RATE FUNCTION 010F 22 ; 010F CF 23 RST 8 ; CALL THE MOS 0110 CF 24 DEFB ZPRM ; OUTPUT A MESSAGE 0111 42617564 25 DEFM "Baud Rate Reset to 4800." 0129 0D8A 26 DEFB CR,LF+80H ; END MESSAGE 012B ED7B3001 27 LD SP,(STAK) ; RESTORE DOS STACK 012F C9 28 RET ; AND RETURN TO DOS 0130 29 ; 0130 30 STAK DEFS 20 ; RESERVE SOME STACK MEMORY 0144 31 END ; ALL DONE. Pass 2 errors: 00 *WARNING* ORGs used: 01 Symbol Table used: #0050 out of #4800.  END ; ALL DONE. Pass 2 errors: 00 *WARNING* ORGs used: 01