* * North Star PASCAL Input/Output Routine * * This I/O routine is for use with North * Star Pascal Ver. 1.0 and a Sol computer. * * Written by: Stephen Maguire July, 1980 * P.O. Box 3742 DT * Anchorage, AK 99510 * * It provides the following support: * * a) It correctly interprets and performs * the GOTOXY procedure that comes with * the system so that BINDER need never * be used. This allows instant cursor * positioning without the need to write * the "necessary" GOTOXY procedure de- * scribed in the manual. * * b) It supports PRINTER: so that output * can be printed out. The routine is * for an NEC Spinwriter 5510, but will * work for any serial printer if wired * according to protocol shown below. * * Spinwrtr pin Sol Serial pin * * TX DATA 2 3 RX DATA * RX DATA 3 2 TX DATA * GND 7 7 GND * CTS 5| * DSR 6| 20 DTR | denotes common * CD 8| connection * |6 DSR * DTR 20 |8 CD * REV CHA 19 5 CTS See Note below: * * Note: In this driver, the Reverse Channel * pin of the Spinwriter is used in the "LOW" * mode by setting #5 of SW1 to "ON" (up) on * the control panel circuit board. (G9BNF) * This results in a "high" to the Sol when * characters can be accepted. If the printer * is unplugged or turned off, the Sol still * sees a high because of its own internal * circuitry and will continue sending char- * acters. This prevents a program hang (and * possibly a crash) if the printer is not * available. * * c) If input is asked of the printer, input * from the keyboard is checked for instead. * * d) If a control-p is sent to CONSOLE:, output * to CONSOLE: is sent to PRINTER: instead. * This continues until another control-p is * encountered. (The control-p may be typed * at the keyboard or output in a program.) * * e) On initialization, the memory is sized and * then waits for either a carriage return * or a hex value to set the memory limit. * This allows the user to "protect" high * memory if necessary. * * f) The underline character can be printed * in order to facilitate compatibility * with other systems. * * g) Control-L erases to end of line. * * h) The bell character is sent to PRINTER: * instead of to CONSOLE:. * * org 2400H - SYSTEM.NSTAR2 (memory at 2000H) * org 400H - SYSTEM.NSTAR0 (memory at 0000H) * ORG 400H * TRUE EQU 0FFH FALSE EQU 0 * CHBEL EQU 07H The bell CHLFE EQU 0AH Linefeed CHCLR EQU 0BH CLEAR screen character CHFFD EQU 0CH Formfeed CHCR EQU 0DH Carriage return CHOME EQU 0EH HOME CURSOR character CHDLE EQU 10H Control-p CHESC EQU 1BH ESCAPE character CHUND EQU 5FH underline character CHDEL EQU 7FH The DEL character ASCII EQU 7FH largest ASCII * * Equates determined by STANDARD SOLOS * SOLOUT EQU 0C019H Solos output routine OCHAR EQU 0C098H print an underline CLINE EQU 0C0F4H erase to end of the line VDADD EQU 0C11CH calculate screen address SHEX EQU 0C340H convert ASCII to binary HEOUT EQU 0C40BH print register A in ASCII NCHAR EQU 0C808H X coordinate of cursor LINE EQU 0C809H Y coordinate of cursor BOT EQU 0C80AH Text offset * * CONSOLE: device (keyboard) * CSTAT EQU 0FAH Keyboard status port CDATA EQU 0FCH Keyboard data port CRDYINP EQU 1 * CRDYOUT EQU 2 (Not used) * * PRINTER: (no input -- CONSOLE: input * is used instead) * PSTAT EQU 0F8H Printer status port PDATA EQU 0F9H * PRDYINP EQU 2 (Not used) PRDYOUT EQU 0A0H "high" on CTS and TBE pins * * REMOTE: device (not supported) * * RSTAT EQU 6 (For optional extra device. * RDATA EQU 0 Values are from the sample I/O * RRDYINP EQU 2 routine given in the manual. * RRDYOUT EQU 1 OK for tape I/O if the * RSTROBE EQU 80H required code is written.) * RPOFLG EQU 20H * * NOTRDY EQU 9 Not-ready value DCTRLB EQU 0E8H High byte of standard PROM DDENS EQU 80H Double density SDENS EQU 0 Single density ONESIDE EQU 0 For single sided drives TWOSIDE EQU 40H Quad capacity drives SBLKTRK EQU 5 blocks/track in single-dens DBLKTRK EQU 10 blocks/track in double-dens * * * * * * * * * * * * * * * * * * * * * * * * Set line below according to your drives * CHARACS EQU TWOSIDE+DDENS+DBLKTRK (Quad) * * * * * * * * * * * * * * * * * * * * * * * NSJTST EQU $ STRTSR EQU NSJTST+512 * * CONSOLE: routine addresses * CONOCL JMP ONLINE Keyboard is always "ready" JMP CONINP Keyboard in CONESC JMP CONOUT Video out JMP CONST * * PRINTER: routine addresses * PTRONL JMP ONLINE Keyboard is always "ready" JMP CONINP If input, go to CONSOLE: in JMP PRNT2 * * REMOTE: routine addresses * REMONL JMP OFFLIN Offline (not supported) JMP REMINP JMP REMOUT * JMP NSMSIZ How much memory is available? JMP OFFLIN No system clock, it is offline JMP MACINT The initialization routine * DV4CHR DB CHARACS Device characteristics DV5CHR DB CHARACS (set for your drives) DV9CHR DB CHARACS DV10CHR DB CHARACS * EXPANSN DW 0 For future use * * CONSOLE: input (PRINTER: input) * CONINP IN CSTAT Has a key been typed? CMA . Inverse the value ANI CRDYINP Strip the value JZ CONINP No, keep waiting IN CDATA Yes, get the character CPI CHDLE Has a control-p been entered RNZ . ORI 80H Ctrl-p's have high bit set RET . * * CONSOLE: output * CONOUT MOV A,C Get the character ANI ASCII MOV C,A Save the stripped value * CPI CHBEL If bell, send to printer JZ PRNT2 * CPI CHESC Escape says GOTOXY JNZ CON0 CALL VDADD MOV A,M Remove the cursor ADI 80H MOV M,A MVI A,1 Set flag to indicate so JMP GOTO3 * CON0 CPI CHDLE ctrl-p, toggle JNZ CON1 LDA TOGGLE Get the switch ADI 80H Now flip it STA TOGGLE XRA A RET * CON1 LDA XYDATA Is it GOTOXY? ORA A JZ CON2 Yes, it is * * GOTOXY makes "ESC","=",y,x to screen address * GOTOXY CPI 1 ESCAPE has been received, JNZ GOTO0 Now check for the "=" sign MOV A,C CPI '=' JZ GOTO2 Yes, its the "=" sign XRA A Error, abort GOTOXY procedure STA XYDATA JMP CONOUT And output the Character * GOTO0 CPI 2 Calculate the row value JNZ GOTO1 MOV A,C Get the row value SBI 32 Sub 20H to get correct value ANI 0FH Make sure value in range STA LINE JMP GOTO2 * GOTO1 MOV A,C Calculate column value SBI 32 Subtract the offset ANI 3FH Make sure value in range STA NCHAR Store the value CALL VDADD Calculate screen address MOV A,M Save character at cursor pos ORI 80H Put the cursor there MOV M,A This does it * LDA TOGGLE If print on, output CR/LF ORA A CNZ PRNT0 * GOTO2 LDA XYDATA Increment pointer so we INR A know which argument to get. ANI 3 * GOTO3 STA XYDATA Save the value XRA A RET . * * All done with the GOTOXY procedure * CON2 LDA TOGGLE If PRINTER: is on, ORA A send it the output JNZ PRINT * MOV A,C CPI CHFFD Formfeed character? JNZ CON3 No, so go print character PUSH H HL cannot be destroyed CALL VDADD PUSH H Save this screen address CALL CLINE Call erase POP H Get it back MVI M,0A0H Put on the cursor POP H XRA A RET . * CON3 CPI CHDEL Delete?, put cursor-left JNZ CON4 MVI A,1 * CON4 CPI CHUND allow underline JNZ CON5 PUSH H Save these registers PUSH B MOV B,A Put the character in B CALL OCHAR Output the character CALL VDADD Now, put on the cursor MOV A,M Do it now ORI 80H MOV M,A JMP CON6 Exit gracefully * CON5 PUSH H Save all registers, PUSH B MOV B,A Put the character in B CALL SOLOUT Now, put to screen * CON6 POP B Restore the registers POP H XRA A RET * * CONSOLE: input status * CONST IN CSTAT CMA . ANI CRDYINP MVI A,FALSE RZ . Return now if "not ready" MVI A,TRUE * * REMOTE: not implemented so do RETURN * REMIN EQU $ REMOUT RET . * * PRINTER: output (via control-p toggle) * PRINT MOV A,C Get the character CPI CHCR JZ PRNT2 CPI CHLFE JZ PRNT2 CPI CHOME Home?, print C/R, LF JZ PRNT0 CPI CHCLR Clear also JNZ PRNT1 * PRNT0 MVI C,CHCR Print it CALL PRINT MVI C,CHLFE JMP PRINT * PRNT1 CPI 20H JC ONLINE Control char?, ignore it * * PRINTER: output (standard output routine) * PRNT2 IN PSTAT ANI PRDYOUT CPI PRDYOUT JNZ PRNT2 Loop until ready MOV A,C ANI ASCII OUT PDATA * ONLINE XRA A RET . * OFFLIN MVI A,NOTRDY RET * NSMSIZ LHLD MEMORY Get memory size XTHL PCHL Return now * * Boot-up initialization * MACINT LXI H,MES1 Print start message CALL PRASC * LXI H,ENDMARK Start sizing at end MVI A,0AAH Test byte SIZE MOV B,M Save this memory location MVI M,0AAH Put in test byte CMP M OK? If not, ROM or no memory MOV M,B Put the old value back INX H Move to the next location JZ SIZE * DCX H Point to last good location DCX H MOV A,L Make HL an even number ANI 0FEH MOV L,A XCHG . DE has last memory location * LXI H,MES2 Print this message CALL PRASC CALL PRHEX Now, print the value MVI C,' ' Print a following blank CALL CONOUT * CALL VDADD Get the cursor address PUSH H Save this MVI B,0 So far, no characters DIFSIZE CALL CONIN Check for input JZ DIFSIZE None yet CPI CHCR Carriage return? JZ DIF4 Terminate input CPI CHDEL Delete? JNZ DIF3 No, much be a hex number * MOV A,B If no characters typed, ORA A JZ DIFSIZE Then don't back up DCR B Else adjust character count DCR B (for later adjustment) MVI A,CHDEL-20H Output back-up * DIF3 INR B CALL CON5 allow delete JMP DIFSIZE Go get more input * DIF4 CALL VDADD Get cursor location MVI M,' ' Erase the cursor POP H Get start location of hex MOV A,B Any numbers been entered? ORA A JZ DIF5 If not, use calculated value XCHG . Otherwise, CALL SHEX Convert MOV A,L Make sure the value is even ANI 0FEH MOV L,A XCHG . Put the value in DE * DIF5 XCHG . This puts DE in HL SHLD MEMORY Save it for later RET * * Message print routine * PRASC XRA A This tests end-of-msg CMP M At end? RZ . If so, return immediately MOV C,M Get the character CALL CONOUT Send it out INX H Bump pointer to next JMP PRASC+1 keep looping * * PRHEX print value of DE as ASCII * PRHEX MOV A,D Print D CALL HEOUT MOV A,E Print E JMP HEOUT * * Messages and data storage * MES1 DB CHCLR ASC 'UCSD Pascal for Solos' DB CHCR,CHLFE,CHLFE ASC 'Sizing memory' DB CHCR,CHLFE,0 * MES2 ASCZ 'Memory available to address: ' MEMORY DB 0 XYDATA DB 0 TOGGLE DB 0 * ENDMARK EQU $ * END *