home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
BEEHIVE
/
UTILITYS
/
INITP6.ARC
/
INITP6.ASM
next >
Wrap
Assembly Source File
|
1990-07-21
|
19KB
|
693 lines
; _______________________________________
; I I
; I NEC-P6 PRINTER INITIALISATION I
; I I
; I Probably works equally well for I
; I sundry other 24-pin dot matrix I
; I printers (e.g. Epson LQ1500 ??) I
; I but I haven't had access to the I
; I printer manuals to be able to I
; I check this. I
; I I
; I Steve Filan, September 4th 1987 I
; I_______________________________________I
; Several elements have been adapted from:-
; Barbier, K. (1983). CP/M Assembly Language
; Programming. Englewood Cliffs. Prentice Hall.
; and/or from:-
; Leventhal, L.A. (1978). 8080A/8085 Assembly
; Language Programming. Berkeley. Osborne/
; McGraw-Hill.
; _______________________________________
; I I
; I Preliminaries I
; I_______________________________________I
;______ Set up symbols for codes for ASCII characters
CR EQU 0DH ;Carriage return
LF EQU 0AH ;Line feed
CTRLZ EQU 1AH ;Osborne clear-screen code
ESC EQU 1BH ;Escape
FS EQU 1CH ;File separator
PAGE EQU 0CH ;Form feed.
;______ Set up codes for CP/M's CBIOS I/O functions
RCONF EQU 1 ;Read from console to [A]
WCONF EQU 2 ;Write [A] to console
WLISF EQU 5 ;Write [A] to printer
RBUFF EQU 10 ;Read a console line to buffer
;______ Define addresses
; Addresses for:-
RBOOT EQU 0 ;Re-boot of CP/M
BDOS EQU 5 ;BDOS call vector
TPA EQU 0100H ;Transient Program Area
; _______________________________________
; I I
; I START OF MAIN PROGRAM I
; I_______________________________________I
ORG TPA
START:
LXI SP,STAK ;Set up user's stack
START1:
CALL SPMSG ;Clear screen
DB CTRLZ,0
CALL TWOCR ;Skip a couple of lines, then
CALL SPMSG ;Give sign-on message.
DB CR,LF,LF
DB 'Printer initialisation routine'
DB ' by Steve Filan, September 4th 1987.'
DB CR,LF,LF
DB 'This utility first resets the printer to'
DB ' default (switch-on) status,'
DB CR,LF
DB 'then offers menus for various options.'
DB CR,LF,LF
DB 'Make sure that the printer is connected '
DB 'and switched on.'
DB CR,LF
DB 'Are you ready to proceed?'
DB CR,LF,0
; Check if ready.
CALL GETYN ;Ready to go?
CPI 'Y' ;If 'Y', proceed,
JNZ RBOOT ; ... else, re-boot system.
; Reset NEC P6 defaults first.
CALL SPMSGL
DB FS,'@',0
; Set A4 size (70 lines at default spacing).
CALL SPMSGL
DB ESC,'C',70,0
;______ OFFER PRINT-SIZE MENU _______________________
CALL CLRSCR ;Set up screen
CALL SPMSG ;Offer menu
DB ' PRINT-SIZE MENU',CR,LF
DB ' ===============',CR,LF,LF
DB ' 1 = 10-pitch',CR,LF
DB ' 2 = 12-pitch',CR,LF
DB ' 3 = 15-pitch',CR,LF
DB ' 4 = 17-pitch',CR,LF
DB ' 5 = 20-pitch',CR,LF,LF,0
CALL GET15 ;Get a response, 1 to 5.
CPI 1 ;Did response = 1 ?
JNZ M2
CALL SPMSGL ; Yes, set 10 pitch.
DB ESC,'P',0
CALL SPMSG ;Confirm
DB CR,LF,'10 pitch set',CR,LF,0
JMP MENU2 ;To next menu.
M2: CPI 2 ;Did response = 2 ?
JNZ M3
CALL SPMSGL ; Yes, set 12-pitch.
DB ESC,'M',0
CALL SPMSG ;Confirm
DB CR,LF,'12 pitch set',CR,LF,0
JMP MENU2 ;To next menu.
M3: CPI 3 ;Did response = 3 ?
JNZ M4
CALL SPMSGL ; Yes, set 15-pitch
DB ESC,'g',0 ;
CALL SPMSG ;Confirm
DB CR,LF,'15 pitch set',CR,LF,0
JMP MENU2 ;To next menu,
M4: CPI 4 ;Did response = 4 ?
JNZ M5
CALL SPMSGL ; Yes, set 17-pitch.
DB ESC,'P',ESC,15,0
CALL SPMSG ;Confirm
DB CR,LF,'17 pitch (condensed 10 pitch) '
DB 'set.',CR,LF,0
JMP MENU2 ;To next menu
M5: ;Response = 5.
CALL SPMSGL ;Set 20 pitch.
DB ESC,'M',ESC,15,0
CALL SPMSG ;Confirm
DB CR,LF,'20 pitch (condensed 12 pitch) set.'
DB CR,LF,0
;______ OFFER PRINT-MODE MENU _______________________
MENU2:
CALL CLRSCR ;Set up new screen
CALL SPMSG ;Offer menu
DB ' PRINT-MODE',CR,LF
DB ' ===============',CR,LF,LF
DB ' 1 = Draft quality',CR,LF
DB ' 2 = Letter quality',CR,LF,0
CALL GET12 ;Get a response, 1 or 2.
CPI 1 ;Did response = 1 ?
JNZ M6
CALL SPMSGL ; Yes, set draft quality.
DB ESC,'x',0 ; ESC-x-0 - careful with '0'
LDA 0 ; .. send on its own.
CALL LO
CALL SPMSG ;Confirm
DB CR,LF,'Set for draft quality.',CR,LF,0
JMP MENU3 ;To next menu.
M6: ;Set letter quality.
CALL SPMSGL
DB ESC,'x',1,0
CALL SPMSG ;Confirm
DB CR,LF,'Set for letter quality.',CR,LF,0
; _____ OFFER PRINT-WEIGHT MENU _____________________
MENU3:
CALL TWOCR ;Skip four lines
CALL TWOCR
CALL SPMSG ;Ask if emphasis required.
DB 'Do you want emphasised or double-strike'
DB 'print ? ',0
CALL GETYN ;Prompt for (Y/N) response
CPI 'Y' ;If 'Y', proceed,
JNZ MENU4 ; else go to next menu.
CALL TWOCR ;Skip a couple of lines
CALL SPMSG ;Offer menu.
DB ' 1 = Emphasised only',CR,LF
DB ' 2 = Both emphasised and '
DB 'double-strike.',CR,LF,LF,0
CALL GET12 ;Get response as 1 or 2.
CPI 2 ;Response = 2 ?
JNZ E1 ;No - want emphasised but
; not double
CALL SPMSGL ;Set double-strike on
DB ESC,'G',0
CALL SPMSG ;Confirm
DB 'Double-strike set',CR,LF,0
E1: ;Set emphasised print on.
CALL SPMSGL
DB ESC,'E',0
CALL SPMSG ;Confirm
DB 'Emphasised print set',CR,LF,0
;______ OFFER LINE-SPACING MENU _____________________
MENU4:
CALL CLRSCR ;Set up new screen
CALL SPMSG ;Offer menu
DB ' LINE-SPACING MENU',CR,LF
DB ' =================',CR,LF,LF
DB ' 1 = Normal 6 lines/inch',CR,LF
DB ' 2 = Double-space, 3 lines/inch',CR,LF
DB ' 3 = One-and-a-half space,'
DB ' 4 lines/inch',CR,LF
DB ' 4 = c. 6.67 lines/inch, gives about '
DB '78 lines per page',CR,LF
DB ' (OK with 15-, 17- 20- pitch).'
DB CR,LF
DB ' 5 = c. 7.33 lines/inch, gives about '
DB '86 lines per page',CR,LF
DB ' (Acceptable with 20 pitch).'
DB CR,LF,LF,0
CALL GET15 ;Get a response, 1 to 5.
CPI 1 ;Did response = 1 ?
JNZ M7
CALL SPMSGL ; Yes, set 6 lines/inch.
DB ESC,'2',0
JMP WINDUP ;To end of job.
M7: CPI 2 ;Did response = 2 ?
JNZ M8
CALL SPMSGL ; Yes, set double space
DB ESC,'A',20,0
JMP WINDUP ;To end of job.
M8: CPI 3 ;Did response = 3 ?
JNZ M9
CALL SPMSGL ; Yes, set 1.5 space
DB ESC,'A',15,0 ;
JMP WINDUP ;To end of job.
M9: CPI 4 ;Did response = 4 ?
JNZ M10
CALL SPMSGL ; Yes, set 6.67 lines/inch
DB FS,'3',54,0
JMP WINDUP ;To end of job.
M10: ;Response = 5.
CALL SPMSGL ;Set 7.33 lines/inch
DB FS,'3',49,0
;______ WIND UP & RETURN TO SYSTEM __________________
WINDUP:
CALL CLRSCR ;Set up new screen
CALL SPMSG ;Offer menu
DB 'Printer-initialisation complete.'
DB CR,LF,LF
DB 'Check print-head is at head-of-form '
DB 'before doing any printing!'
DB CR,LF,LF,LF,0
JMP RBOOT ;All finished ... re-boot.
;_____ End of main program ________________________
; ________________________________________________
; I I
; I Subroutine CLRSCR I
; I I
; I Delay, then open a screen for a new menu. I
; I________________________________________________I
CLRSCR:
CALL DELAY ;Delay for quarter-second
CALL SPMSG ;Clear screen
DB CTRLZ,0
CALL TWOCR ;Skip a couple of lines
RET ;Return
; ________________________________________________
; I I
; I Subroutine DELAY I
; I I
; I Loop for delay of approximately I
; I 255 ms (assuming 4MHz 8080 processor). I
; I Beware -- timing is hardware-sensitive I
; I For commentary, see Leventhal (1978) I
; I Chapter 11. I
; I________________________________________________I
DELAY: ;Delay 255 ms at each call.
MVI A,255
DELAY1: ;Set loop counter
MVI B,255
DELAY2:
DCR B ;Counter = Counter - 1
JNZ DELAY2 ; Continue till Counter = 0
DCR A ;Number of ms = no. of ms - 1
JNZ DELAY1 ;Continue
RET
; ________________________________________________
; I I
; I I N P U T / O U T P U T R O U T I N E S I
; I I
; I Mostly adapted from code in Barbier (1983) I
; I________________________________________________I
;______ Subroutine "CI" _____________________________
; Accept a character from the console keyboard; mask
; to 7 bits to hide possible parity bit; then store
; in Accumulator, register A.
CI:
PUSH B ;Save registers on stack
PUSH D
PUSH H
MVI C,RCONF ;Put read-function code in C
CALL BDOS ;Have read function performed
ANI 7FH ;Mask to 7 bits
POP H ;Recover registers from stack
POP D
POP B
RET ;Return to main routine
;______ Subroutine "CO" _____________________________
; Display the character in Accumulator
; (register [A]) at the console.
CO:
PUSH B ;Save registers on stack
PUSH D
PUSH H
MVI C,WCONF ;Code for write function to C
MOV E,A ;Character moved from A to E
CALL BDOS ;Perform write-console
POP H ;Recover registers from stack
POP D
POP B
RET ;Return to main routine
;______ Subroutine "LO" _____________________________
; Display the character in Accumulator
; (register A) at the printer.
LO:
PUSH B ;Save registers on stack
PUSH D
PUSH H
MVI C,WLISF ;Code for list function to C
MOV E,A ;Character moved from A to E
CALL BDOS ;Send character to printer.
POP H ;Recover registers from stack
POP D
POP B
RET ;Return to main routine
; _____ Subroutines TWOCR and CCRLF _________________
; Send either two or one carriage return/line
; feed sequences to console display.
TWOCR:
CALL CCRLF ;Do twice if called as TWOCR
CCRLF:
MVI A,CR ;Store code for CR
CALL CO ; ... display
MVI A,LF ;Ditto for line feed
JMP CO ;Indirect return via CO.
; _____ Subroutine COMSG ____________________________
; Display on the console a line of text that
; has previously been stored in buffer.
COMSG:
MOV A,M ;Get a character from memory
ORA A ;Dummy "or" operation, to set
RZ ; flag ... return if [A]=0.
CALL CO ;Output character
INX H ;Point to next character
JMP COMSG ; and continue loop
; _____ Subroutine LOMSG ____________________________
; Display on the printer a line of text that
; has previously been stored in buffer.
LOMSG:
MOV A,M ;Get a character from memory
ORA A ;Dummy "or" operation, to set
RZ ; flag ... return if [A]=0.
CALL LO ;Output character
INX H ;Point to next character
JMP LOMSG ; and continue loop.
; _____ Subroutine CIMSG ____________________________
; Subroutine which accepts a line of input from
; the console, storing the text in a buffer.
CIMSG:
PUSH B ;Store registers
PUSH D
PUSH H
LXI H,INBUF+1 ;Zero character counter
MVI M,0
DCX H ;Set maximum line length
MVI M,80 ; as 80 (decimal).
XCHG ;Reset pointer to DE register
MVI C,RBUFF ;Set code for read-buffer fn.
CALL BDOS ; of BDOS, & call it.
LXI H,INBUF+1 ;Get char. counter
MOV E,M ; into LSB of DE register
MVI D,0 ;Zero MSB of DE register
DAD D ;Add length to start
INX H ; plus 1 points to end
MVI M,0 ;Insert terminator character.
POP H ;Restore all registers
POP D
POP B
RET
; _____ Subroutine SPMSG ____________________________
; Subroutine to display message "in-line"
; during program running.
; (Use zero byte as end-of-buffer signal).
SPMSG:
XTHL ;Get return address to HL
XRA A ;Clear flags & accumulator
ADD M ;Get one message character
INX H ;Point to next
XTHL ;Restore stack for
RZ ; return if done
CALL CO ;Else, display character
JMP SPMSG ; ... and do another.
; _____ Subroutine SPMSGL ___________________________
; Subroutine to send "in-line" message to
; printer.
; (Use zero byte as end-of-buffer signal).
SPMSGL:
XTHL ;Get return address to HL
XRA A ;Clear flags & accumulator
ADD M ;Get one message character
INX H ;Point to next
XTHL ;Restore stack for
RZ ; return if done
CALL LO ;Else, send a character
JMP SPMSGL ; ... and do another.
; _____ Subroutine GETYN ____________________________
; Get (upper- OR lower- case) Y for yes or
; N for no, from console.
GETYN:
CALL SPMSG ;Prompt for input
DB CR,LF,' (Y/N)?: ',0
CALL CI ;Get character at console
ANI 01011111B ;Convert to upper-case
CPI 'Y' ;Return with zero = Yes
RZ
CPI 'N' ;Non-zero = NO
JNZ GETYN ; ... else, try again ...
CPI 0 ;Reset zero flag
RET ;All done.
;______ Subroutine GET12 ____________________________
; Get an integer (1 or 2) from the console.
; See Leventhal (1978) pp. 7-6 to 7-8.
GET12:
CALL SPMSG ;Prompt for input
DB 'Enter a digit 1 or 2: ',0
CALL CI ;Get input character, masked
; to 7 bits, store in [A]
SUI '0' ;Subtract ASCII '0' to
; convert ASCII to integer.
JC GET12 ; Try again .. outside range.
CPI 3 ;Check upper limit
JNC GET12 ; Try again .. too big!
RET ;Integer 1 or 2 found OK.
;______ Subroutine GET15 ____________________________
; Get an integer (1..5) from the console.
; See Leventhal (1978) pp. 7-6 to 7-8.
GET15:
CALL SPMSG ;Prompt for input
DB 'Enter a digit 1..5: ',0
CALL CI ;Get input character, masked
; to 7 bits, store in [A].
SUI '0' ;Subtract ASCII '0' to
; convert ASCII to integer
JC GET15 ; Try again .. outside range.
CPI 6 ;Check upper limit
JNC GET15 ; Try again .. too big!
RET ;Integer 1..5 found OK.
; _______________________________________
; I I
; I Set up storage space for memory I
; I variables and input/output buffer. I
; I_______________________________________I
INBUF:
DS 83 ;Line input buffer
NEXT:
DS 2 ; Next DMA address
DS 64 ;Reserve space for stack.
STAK:
DB 0 ;Set pointer to top of stack
BUFFR: ;Remainder of memory, to CCP,
; is free buffer space.
; _____ End of code _________________________________
END
; is free buffer space.
; _____ End of code _________________________________