LABEL PRINT

Developer(s): Algis Gedris
Date: 198x
Type: Program
Platform(s): TS 2068
Tags: Tape

LABEL PRINT formats and prints adhesive labels to an Epson-compatible SG-10 dot-matrix printer via an AERCO interface. The program accepts up to four lines of text — a title (15 characters max) and three detail lines (59 characters max each) — centering each line automatically using TAB calculations based on string length. It uses OUT 123 commands to send ESC sequences directly to the printer port, switching between condensed (ESC 14) and normal (ESC 15) pitch modes, and issuing an ESC 64 form-feed between copies. Lines 9980–9995 form a separate initialization and splash-screen block that uses machine code loaded from tape (at address 32256 and 64456) to render scaled text graphics, patching the system with a series of POKEs to configure the AERCO interface and printer driver before jumping to the main program at line 1.


Program Structure

The program divides into two functionally distinct regions. Lines 10–160 form the interactive label-printing application, and lines 9980–9998 constitute a machine code loader, splash-screen renderer, and save/initialization block. Under normal use the high-numbered lines are never reached from the main flow; they represent a separate boot sequence that patches the system, loads code from tape, and then transfers control to line 1 (which falls through immediately to line 10).

Line rangePurpose
4–6, 9REM blocks holding title/credits text
10–12Setup: BORDER/INK/PAPER/POKEs, prompt for title string A$
13–14Send condensed-on ESC sequence to printer; PRINT title to screen centered
20–44Prompt and validate lines B$, C$, D$; PRINT to screen
50–54Flashing “CORRECT?” prompt; wait for keypress; restart if “N”
100–132Copy loop: send each label to printer with centering and pitch changes
140–160Post-print prompts for more copies or new title; final CLS/STOP
9980–9985Splash screen using machine code scaled-text renderer
9990–9992AERCO interface configuration via POKEs; load printer driver from tape
9993–9995Second splash screen; PAUSE; GO TO 1 to start main program
9998SAVE block — saves BASIC and two CODE segments to tape

Printer Port Control via OUT

Rather than using the standard LPRINT mechanism for control codes, the program sends ESC sequences by writing directly to port 123 with OUT 123,27 (ESC) followed by a second OUT for the mode byte. Three printer modes are engaged:

  • OUT 123,27: OUT 123,14 — ESC SO, selects condensed (double-wide) mode for the title line
  • OUT 123,27: OUT 123,15 — ESC SI, selects condensed normal-width mode for detail lines
  • OUT 123,27: OUT 123,64 — ESC @, resets the printer between copies

Text Centering

The program computes horizontal centering differently for screen and printer output. On screen (line 14), the title is positioned with TAB 16-(LEN A$/2), centering within the 32-column display. For the printer (lines 120–128), TAB offsets of 9-(LEN A$/2) and 32-(LEN B$/2) are used, reflecting the narrower condensed-mode column width for the title versus the wider normal-mode column for detail lines.

Key Press Wait Idiom

Lines 52–54 use the standard busy-wait pattern: IF INKEY$="" THEN GO TO 52 spins until a key is detected, then line 54 checks whether it is “N” to restart input. This two-line construct correctly handles the brief window between the first and second INKEY$ reads, though a rapid typist could theoretically miss the “N” check if the key is released before line 54 executes.

Machine Code Splash Screen (Lines 9980–9984)

The initialization path loads 300 bytes of machine code to address 32256 from a tape file named “TITLE”. This code implements a scaled-text renderer. The interface is entirely POKE-based: line 9984 writes a parameter block into RAM starting at address 23306 — x-position, y-position, x-scale, y-scale, attribute byte, and then the character codes of the string, terminated by 255. Calling USR 32256 invokes the renderer, and the return value is discarded (assigned to w only to trigger the call).

  • Address 23306 onwards: x, y, xs, ys, ink-byte, char codes, 255 terminator
  • Each splash loop iteration increments yy by 30 and uses the loop index f as both x-scale and y-scale
  • DATA statements embedded at the end of line 9981 and 9993/9994 supply the label strings and INK colors

AERCO Interface Configuration (Lines 9990–9992)

Line 9990 applies a large block of POKEs into the 64000–64900 range, patching what appears to be the AERCO interface driver code already resident in that area (loaded via line 9992). These POKEs inject printer ESC sequences for initialization, condensed mode, and form-feed directly into the driver’s command tables. Line 9992 then loads 1111 bytes of machine code to address 64456, configures a JP instruction at addresses 26703–26704 (pointing into the driver), and starts the second splash sequence.

Anomalies and Notes

  • Line 12 uses LEN A$ >=16 to reject titles longer than 15 characters, looping back to line 10 which re-initializes BORDER/PAPER and repeats the POKE statements as a side effect of the validation loop.
  • The POKE at line 10 — POKE 23658,8 — enables CAPS LOCK, ensuring uppercase input throughout.
  • Line 100’s comment “14 spaces between quotes” documents a deliberate use of spaces to erase the FLASH “CORRECT?” message before the copy-count INPUT.
  • Line 9995 executes GO TO 1, which targets a non-existent line; execution falls through to line 10, the first actual line of the main program. This is intentional.
  • The POKE 23609,60 at line 10 sets the system’s REPDEL value, affecting key repeat delay.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Source Code

    4 REM \{20}\{1}    LABEL PRINTER 2A/P \{20}\{0}    
    5 REM \{20}\{1}    LABEL PRINTER /    \{20}\{0}         \{20}\{1}    FOUR LINES         \{20}\{0}         \{20}\{1}    CONDENSED/ 2,3 & 4 \{20}\{0}\{20}\{0}        
    6 REM \{20}\{1}    SG-10 PRINTER      \{20}\{0}         \{20}\{1}    AERCO INTERFACE    \{20}\{0}         \{20}\{1}    ALL SWITCHES UP    \{20}\{0}     
    9 REM \{20}\{1}      MODIFIED BY-     \{20}\{0}         \{20}\{1}    ALGIS E. GEDRIS    \{20}\{0}
   10 BORDER 2:INK 0:PAPER 6:POKE 64459,79:POKE 23658,8:POKE 23609,60
   11 CLS :INPUT "PROGRAM TITLE:*(15 LETTERS MAX)";A$
   12 IF LEN A$ >=16 THEN GO TO 10
   13 OUT 123,27:OUT 123,14
   14 PRINT TAB 16-(LEN A$/2);A$
   20 INPUT "LINE #2 INFO:(MAX *59) ";B$
   22 IF LEN B$>59 THEN GO TO 20
   24 PRINT B$
   30 INPUT "LINE #3 INFO:(MAX *59) ";C$
   32 IF LEN C$>59 THEN GO TO 30
   34 PRINT C$
   38 PRINT :PRINT :PRINT :PRINT :PRINT 
   40 INPUT "BOTTOM LINE #4:(59 *MAX)";D$
   42 IF LEN D$>59 THEN GO TO 40
   44 PRINT D$
   50 PRINT AT 21,8; FLASH 1;"CORRECT? (/N)"
   52 IF INKEY$="" THEN GO TO 52
   54 IF INKEY$="N" THEN GO TO 11
  100 PRINT AT 21,8;"             ":INPUT "NUMBER OF COPIES :";X:REM 14 spaces between quotes
  110 FOR I=1 TO X
  111 OUT 123,27:OUT 123,14
  120 LPRINT TAB 9-(LEN A$/2);A$
  121 OUT 123,27:OUT 123,15
  122 LPRINT TAB 32-(LEN B$/2);B$
  124 LPRINT TAB 32-(LEN C$/2);C$
  126 LPRINT :LPRINT :LPRINT :LPRINT :LPRINT 
  128 LPRINT TAB 32-(LEN D$/2);D$
  130 LPRINT :LPRINT 
  131 OUT 123,27:OUT 123,64
  132 NEXT I
  140 INPUT "MORE? (Y/N): ";X$
  142 IF X$="Y" THEN GO TO 100
  150 INPUT "ANOTHER TITLE? (Y/N): ";X$
  152 IF X$="Y" THEN GO TO 11
  160 CLS :PRINT AT 10,8;"(WORK COMPLETED)":STOP 
 9980 STOP 
 9981 BORDER 2:PAPER 6:CLS :LET yy=-21:FOR f=1 TO 4:LET xs=f:LET ys=f:READ p$,i:INK i:LET yy=yy+30:GO SUB 9983:NEXT f:GO TO 9985:DATA "GEMINI SG/10",2,"INTERFACE",4,"AERCO",3,"ALL-UP",1
 9982 CLEAR 32255:INK 7:LOAD "TITLE"CODE 32256,300:GO TO 9981
 9983 LET xx=(256-8*xs* LEN p$)/2
 9984 LET i=23306:POKE i,xx:POKE i+1,yy:POKE i+2,xs:POKE i+3,ys:POKE i+4,8:LET i=i+4:LET w= LEN p$:FOR n=1 TO w:POKE i+n, CODE p$(n):NEXT n:POKE i+w+1,255:LET w= USR 32256:RETURN 
 9985 PRINT AT 18,8;"LLIST  = LLIST"; AT 19,8;"LPRINT = LPRINT"; AT 20,8;"COPY   = LPRINT CHR$ 1"
 9990 POKE 64464,76:POKE 64460,10:POKE 64782,\{20}\{0}3:POKE 64783,27:POKE 64784,51:POKE 64785,16:POKE 64799,4:POKE 64800,27:POKE 64801,75:POKE 64802,0:POKE 64803,1:POKE 64834,2:POKE 64835,27:POKE 64836,64:POKE 64850,24:POKE 64874,1:POKE 64886,35:POKE 64888,195:POKE 64894,35
 9992 POKE 26704,251:POKE 26703,205:POKE 64456,1:POKE 64458,0:POKE 64457,0:POKE 64459,79:INK 6:LOAD "SG-10/CODE"CODE 64456,1111
 9993 BORDER 2:PAPER 6:CLS :LET yy=-21:FOR f=1 TO 3:LET xs=f:LET ys=f:READ p$,i:INK i:LET yy=yy+30:GO SUB 9983:NEXT f:DATA "LABEL",2,"PRINTER",4,"CONDENSED",3
 9994 LET yy=130:LET f=2:LET xs=f:LET ys=f:READ p$,i:INK i:GO SUB 9983:DATA "VERSION 5A",2:PAUSE 160
 9995 GO TO 1
 9998 SAVE "LABEL 5A" LINE 9982:SAVE "TITLE"CODE 32256,300:SAVE "SG-10/CODE"CODE 64456,1111

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top