PRINTER CONTROL PROGRAM
by D. Kingery, PUGSKUG, August 1987

(You modify and assemble this printer control program)

This article is a sort of takeoff on the articles Stan Gee did
for a while on simple programs (see December 1983 through May
1984 issues).  For those of you who may be interested in
assembler code, the following program is very versatile. Its
purpose is control of printer functions, and I'll give some
variations.

This article only touches the surface; if you're interested in
more information, I suggest "SOUL OF CP/M" by Waite and Lafore or
"CP/M REVEALED" by Dennon.  In any event, it would help to read
Stan Gee's articles in prior issues (December 1983 through May
1984).

By the way, I wrote this article a long time ago and never
printed it.  I hope everything works OK.  If there's any
interest, it would be easy to put together a menu-driven, menu-
bypassable program that you could install for your own printer.

Using your favorite word processor (in the nondocument mode if
it's Wordstar), type the following program into a file called
"PRO17.ASM":

PRO17 has been written to change the font on a ProWriter printer
to 12-pitch.
     ;
org  100h
     ;
 
This part changes the printer pitch.


              ;
        lxi   h,msg1           ;load msg1 address
loop1:  mov   e,m      ;put character in 'e'
        push  h        ;save address
        mvi   c,05h    ;signal 'LIST OUTPUT'
        call  05h      ;call BDOS to send the
                       ;character to the printer
        pop   h        ;retrieve address
        inx   h        ;get ready for the next
                       ; character
        cmp   m        ;BUT, look at it first 
        jnz   loop1      ;if it's not zero, go 
                       ;back and process it
              ; 

This part prints a message to the screen.

              ;
        lxi   h,msg2           ;load msg2 address
loop2:  mov   e,m       ;put character in 'e'
        push  h         ;save address
        mvi   c,02h     ;signal 'LIST OUTPUT'
        call  05h       ;call BDOS to put the 
                        ; character on the screen
        pop   h         ;retrieve address
        inx   h         ;get ready for the next 
                        ;       character
        cmp   m         ;BUT, look at it first
        jnz   loop2       ;if it's not zero, go 
                        ;  back and put it on the
                        ;          screen       
        jp    00h       ;otherwise, warm boot
              ;
              ;
msg1:   db    1bh,45h
        db    0dh,0ah,00h
              ;
              ;
msg2:   db   1ah,0dh,0ah,0ah,0ah,0ah,'The ProWriter '
        db   'has just been switched to 12-pitch (if'
        db   ' it was hooked up).  Have a good day!'
        db   0dh,0ah,0ah
        db   00h
end

You can type this verbatim without understanding any of it, if
you like, but your CP/M handbook (the one that came with your
machine) will explain anything you want to know about 8080
assembler language.  One thing you may have figured out for
yourself:  anything preceded by a semicolon is a comment.

After you get it typed in and saved to the disk, you can assemble
the program.  For this, you need ASM.COM and LOAD.COM, both of
which should be on the systems utilities disk that came with your
KayPro.  Load that disk and log on to it.  Now, type:

asm x:pro12<cr>

where x is the drive that pro12.asm is on if it's not on the
default drive.  You should get a screen printout like this:

CP/M ASSEMBLER - VER 2.0
018B
000H USE FACTOR
END OF ASSEMBLY

Warm Boot

Now, show the directory of the disk that pro12 is on.  You'll see
the following new entries for files generated by asm.com:

PRO12.PRN
PRO12.HEX

If you've made some typing errors, the ASM program will show them
on the screen, and you can go back and correct them.  If there
are no errors shown, type:

load pro12<cr>

And you'll get a screen printout like this:

FIRST ADDRESS 0100
LAST ADDRESS  018A
BYTES READ    008B
RECORDS WRITTEN 02

When you check the disk directory, you'll find another new file
called PRO12.COM, and if you type:

pro.12<cr>

AND your printer is a ProWriter AND it's plugged in AND turned
on, etc., etc., your new program will set your printer to 12-
pitch.

If your printer ISN'T a ProWriter, simply change the line
beginning "msg1" so that it speaks to your printer with
directions that your printer understands.  For the Epson FX-
series printers, enter the "msg1:" line as follows:

msg1:  db 1bh,4dh

or, if you wish:

msg1:  db 1bh,'M'

(omitting the original msg1 line, of course), or for printers
recognizing Diablo protocol, enter the following:

msg1:  db 1bh,1fh,0bh

I know the PRO17program works; I tested it on my ProWriter.  I
have  not tested it on the other two printer types.  If it
doesn't work for you on one of the last two, double-check the
codes against your printer manual.

One last variation; a msg1: command that puts the ProWriter into
expanded condensed mode:

msg1:  db 1bh,45h,0eh

The Epson equivalent is:

msg1:  db 0fh,0eh

You should invent suitable titles for programs like this, of
course.  And that's it for this time folks.
