AERCO Patch

This file is part of and SINCUS Exchange Tape 102 - Utilities & Business. Download the collection to get this file.
Developer(s): Dave Schoenwetter
Date: 198x
Type: Program
Platform(s): TS 2068

This program patches the MTERM machine code package, a terminal emulator, by poking specific byte values into three memory regions starting at addresses 59173, 59188, and 58618. The patch data consists of Z80 machine code bytes stored in DATA statements and read sequentially via a RESTORE/READ/POKE loop driven by subroutine calls at line 4500. The program verifies user readiness before proceeding and prints each address and its new value as confirmation. After patching, the user is instructed to save the modified MTERM back to tape.


Program Analysis

Program Structure

The program is divided into two functional segments. Lines 100130 form a short guard that asks whether the MTERM code is already loaded in memory; a “yes” answer jumps to the patching routine at line 4000, while any other answer prints a message and halts. The main body from 4000 onward performs the patch, displays author contact information, and holds the DATA table and the READ/POKE subroutine.

Patching Mechanism

Three memory ranges are targeted in sequence:

  • 5917359175 (3 bytes) — patched in the loop at lines 40104030
  • 5918859190 (3 bytes) — patched in the loop at lines 40404060
  • 5861858833 (216 bytes) — patched in the loop at lines 40704090

A RESTORE 4100 at line 4000 resets the DATA pointer to the start of the patch table before any reading begins, ensuring the bytes are consumed in the correct order regardless of prior program state.

READ/POKE Subroutine

The subroutine at lines 45104530 is minimal but effective: it reads one byte from the DATA stream into variable a, POKEs it to the current loop address f, prints both the address and the value now held there via PEEK f as a live verification step, then returns. Printing every address/value pair makes the patching process fully visible to the user, which also serves as a rudimentary checksum substitute.

Z80 Machine Code Content

The DATA bytes from line 4100 onward encode Z80 instructions. Notable sequences include:

  • 195 (JP nn) — unconditional jumps at the very start of each small patch block
  • 237, 75 (ED 4B = LD BC,(nn)) and 237, 66 (ED 42 = SBC HL,BC) — extended Z80 instructions
  • 219, 254 / 219, 127 (IN A,(254) / IN A,(127)) — port reads, consistent with keyboard and serial I/O in a terminal context
  • 211, 127 (OUT (127),A) — port 127 output, typical of RS-232 serial hardware interfaces used with MTERM
  • A run of 24 zero bytes at line 4134 suggesting a buffer or padding area within the replaced routine

Data Layout

DATA linesApprox. byte countPurpose
410041026First two small patch blocks (JP targets)
41044184~210Main replacement routine (58618–58833)

Key BASIC Idioms

  • RESTORE 4100 before any READ to anchor the DATA pointer explicitly — good practice when multiple loops consume the same DATA stream sequentially.
  • Using FOR f = addr1 TO addr2 : GO SUB 4500 : NEXT f rather than inline POKE keeps the code compact and reuses a single subroutine for all three address ranges.
  • The subroutine at line 4500 is called via GO SUB 4500, but the actual code starts at line 4510; line 4500 does not exist. This is intentional — the interpreter will execute the next available line (4510) without error, a standard space-saving trick.

Anomalies and Notes

The INPUT prompt at line 100 only branches on the exact string "yes" (lowercase); any variation such as "YES" or "Yes" will fall through to the STOP at line 130. There is no explicit error handling if the DATA runs short relative to the address range — a mismatch would produce an “Out of DATA” error mid-patch, potentially leaving MTERM in a partially modified state. The author’s mailing address embedded in lines 40944096 identifies this as a distributed fix meant to be typed in by users who contacted the author.

Content

Appears On

The workhorse tape — assemble Z80 code, manage databases, analyze statistics, cast I Ching hexagrams, balance your checkbook, and switch between four font styles. SINCUS Tape 102 turns the TS 2068 into a serious productivity machine.

Related Products

Related Articles

Related Content

Image Gallery

AERCO Patch

Source Code

  100 INPUT "DO YOU HAVE MTERM CODE LOADED?"'"         yes/no        ";a$
  110 IF a$="yes" THEN GO TO 4000
  120 PRINT "PLEASE LOAD MTERM CODE AND RUN"
  130 STOP 
 4000 RESTORE 4100
 4010 FOR f=59173 TO 59175
 4020 GO SUB 4500
 4030 NEXT f
 4040 FOR f=59188 TO 59190
 4050 GO SUB 4500
 4060 NEXT f
 4070 FOR f=58618 TO 58833
 4080 GO SUB 4500
 4090 NEXT f
 4092 PRINT ''''''"SAVE YOUR ALTERED MTERM ON TAPE"
 4093 PRINT '''
 4094 PRINT "DAVE SCHOENWETTER"
 4095 PRINT "1335 FARM TO MARKET RD."
 4096 PRINT "ENDWELL, NEW YORK, 13760"
 4099 PRINT '''"all done": STOP 
 4100 DATA 195,126,229
 4102 DATA 195,178,229
 4104 DATA 42,232,238,237
 4106 DATA 75,236,238,3
 4108 DATA 125,185,32,7
 4110 DATA 124,184,32,3
 4112 DATA 195,80,229,62
 4114 DATA 127,219,254,31
 4116 DATA 210,80,229,219
 4118 DATA 127,230,16,32
 4120 DATA 242,126,254,10
 4122 DATA 32,2,62,0
 4124 DATA 254,12,32,2
 4126 DATA 62,0,205,48
 4128 DATA 229,35,195,2
 4130 DATA 229,0,211,127
 4132 DATA 0,219,127,201
 4134 DATA 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
 4136 DATA 0,0,62,13
 4138 DATA 205,48,229,62
 4140 DATA 13,205,48,229
 4142 DATA 62,13,205,48
 4144 DATA 229,33,117,239
 4146 DATA 54,13,6,32
 4148 DATA 43,54,32,16
 4150 DATA 251,125,50,231
 4152 DATA 238,201,33,195
 4154 DATA 229,126,167,32
 4156 DATA 4,62,35,119
 4158 DATA 201,175,24,251
 4160 DATA 203,79,194,40
 4162 DATA 231,245,197,229
 4164 DATA 42,176,229,237
 4166 DATA 75,174,229,237
 4168 DATA 66,32,4,225
 4170 DATA 193,241,201,219
 4172 DATA 127,230,16,32
 4174 DATA 246,10,205,48
 4176 DATA 229,3,62,96
 4178 DATA 184,32,3,1
 4180 DATA 0,94,237,67
 4182 DATA 174,229,24,227
 4184 DATA 0,94,0,94
 4186 DATA 229,219,115,254
 4188 DATA 12,40,4,254
 4190 DATA 10,32,1,175
 4192 DATA 245,42,176,229
 4194 DATA 119,35,62,96
 4196 DATA 188,32,3,33
 4198 DATA 0,94,34,176
 4200 DATA 229,241,225,201
 4510 READ a: POKE f,a
 4520 PRINT f,PEEK f
 4530 RETURN 

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

Scroll to Top