; Printer Setter-upper v2.00 by Alan Sheehan B.E. 10/8/85 ; Modified to v2.00 8/2/85 : Improved illegal character trapping ; Utility .COM file to send control codes to printer ; BDOS EQU 5 ;BDOS call address LSTOUT EQU 5 ;BDOS function for char out to LST: device PRTMES EQU 9 ;BDOS function for console messages INPSTR EQU 10 ;BDOS function for string input ; ORG 0100H ;.COM file start LD DE,TITLE ;addr of title message LD C,PRTMES ;print message CALL BDOS LD DE,PROMPT ;addr of input prompt message LD C,PRTMES ;print it CALL BDOS LD DE,STBUFF ;addr of start of input buffer LD C,INPSTR ;get string input in the buffer CALL BDOS ; ; check input string case and convert to upper case ; also weed out illegal characters ; LD HL,STBUFF+1 ;point to number of chars in buffer LD B,(HL) ;get number of chars INC HL ;point to 1st char UPLOOP LD A,(HL) ;get char CP 30H ;compare with '0' JR C,ISITOK ;go if < '0' CP 3AH ;no need to convert if < : JR C,UP CP 41H ;check for :;<=>? or @ JR C,ERR1 ;go if one of them was found! CP 60H ;check for ` character JR Z,ERR1 ;go if it was found! AND 95 ;convert to upper case CP 47H ;test for illegal char JR NC,ERR1 ;go if illegal LD (HL),A ;write upper case char back to buffer UP INC HL DJNZ UPLOOP ; ; check input string format ; LD HL,STBUFF+1 ;point to number of chars LD B,(HL) INC HL FLOOP LD A,(HL) CP 20H JR Z,SPACE ;test for space INC HL ;look at next char if not space LD A,(HL) CP 20H JP Z,ERR2 ;not 2 digit hex error DEC B LD A,B ;test not end of buffer CP 0 JP M,ERR2 ;end of buffer not expected error JR Z,ERR2 SPACE INC HL ;point to next char DJNZ FLOOP ; ; convert ascii to hex and send to LST: device ; LD HL,STBUFF+1 LD B,(HL) ;get number of chars INC HL ;point to 1st char CLOOP LD A,(HL) ;get ascii char CP 20H JR NZ,NSPACE ;go if not a space INC HL DJNZ CLOOP RET ;return to CCP control ; ; convert 2 digit Ascii to Hex and send it to the LST: device ; NSPACE CALL ASCHEX ;convert 2 digit ascii to hex LD E,C ;put code in E for BDOS LD C,LSTOUT PUSH BC ;save counter PUSH HL ;save pointer CALL BDOS ;send code to LST: device POP HL ;get pointer back POP BC ;get counter back DJNZ CLOOP ;repeat till all codes sent RET ;return to CCP control ; ; check to see if characters < '0' are spaces ; if not they are illegal ; ISITOK CP 20H ;test if its a space JR Z,UP ;go back if it is, otherwise ;it's an illegal character! ; ; error messages ; ; illegal character error ; ERR1 LD DE,ERRM1 ;point to error message ENDERR LD C,PRTMES ;print it CALL BDOS RET ; ERRM1 DB 0DH DB 0AH DB 7 DEFM 'Illegal character error.' DB 0DH DB 0AH DEFM 'Valid characters are: 01234567890ABCDEFabcdef$' ; ; illegal format error ; ERR2 LD DE,ERRM2 JR ENDERR ; ERRM2 DB 0DH DB 0AH DB 7 DEFM 'Illegal input format error.' DB 0DH DB 0AH DEFM 'Input must be in TWO digit Hex.$' ; ; subroutines ==================================== ; ; convert ascii to hexadecimal ; ASCHEX LD C,0 ;initialise storage LD A,(HL) ;get character CALL CVERT ;convert it INC HL ;point to next one DEC B ;reduce count of chars remaining LD A,(HL) ;get 2nd char CALL CVERT INC HL RET ; CVERT SLA C ;allign result for merger SLA C SLA C SLA C SUB 30H ;convert to 0-15 CP 10 JP M,JUMP1 ;go if 0-9 SUB 7 ;adjust A-F to 10-15 JUMP1 ADD A,C ;combine 2 ascii chars to 1 byte code LD C,A ;put result in C RET ; ; main messages ; TITLE DB 0DH DB 0AH DB 0AH DEFM 'Printer Setter-upper v2.00 by Alan Sheehan. B.E. 8/2/85$' ; PROMPT DB 0DH DB 0AH DB 0AH DEFM 'A utility program for sending control codes to the LST: device.' DB 0DH DB 0AH DEFM 'Enter codes in 2 digit Hex form separated by spaces:' DB 0DH DB 0AH DB 24H ; STBUFF DB 0FFH ;define length of buffer DB 0 DS 0FFH ;set aside space for buffer END