Progmerge

Products: ProgMerge
Date: 1982
Type: Cassette
Platform(s): TS 1000

Progmerge is a utility that loads machine code routines into protected user space to enable storing, inserting, and renumbering BASIC program segments. The core functionality is invoked via RAND USR 30000, which stores a marked section of a program (delimited by empty REM statements) or inserts a previously stored section into another program at a REM-marked location. A separate renumbering routine is accessible at RAND USR 31346. Error codes E, G, and I are reported for insufficient memory, missing empty REMs, and illegal GO TO or GO SUB targets respectively.


Program Analysis

Program Structure

The program is a loader and documentation display. Line 10 contains a REM statement that embeds the machine code payload, which is loaded into protected user space during initialization (triggered by the RAND USR 17506 call visible in the header block). Lines 20–180 consist entirely of PRINT statements that describe how to use the utility, interspersed with a simple delay loop and SCROLL calls to page through the text.

Machine Code Integration

The machine code is stored within the REM statement at line 10 — a standard technique for embedding binary data in a BASIC program. The entry point at address 17506 (decimal) is called at load time to relocate or initialize the routines into protected user space, placing them beyond the reach of BASIC’s memory management. Two callable entry points are exposed to the user:

  • RAND USR 30000 — the main store/insert routine, which uses empty REM statements as delimiters to identify the program segment to be stored or the insertion point in the target program.
  • RAND USR 31346 — a standalone renumbering routine that can be called independently.

User Interface and Paging

Because the help text is too long to fit on a single screen, the program uses a busy-wait delay loop (FOR N=1 TO 1000 at lines 70–80) followed by 14 SCROLL calls (lines 100–120) to advance the display. A status message is printed at the bottom of the screen (AT 21,0) during the pause and cleared before scrolling. This is a straightforward but functional approach to multi-page text display without any key-press interaction.

Merge and Renumber Methodology

The documented workflow relies on empty REM statements as in-program markers, a technique that imposes no syntax constraints on the surrounding code. The two-phase operation — first storing a segment with NEW afterward, then loading a second program and calling the same entry point — is handled entirely within the machine code routine. Renumbering after merge is performed automatically, with the standalone RAND USR 31346 entry point available for use independently.

Error Reporting

The machine code routine reports three single-character error codes:

CodeMeaning
EInsufficient memory available
GA required empty REM statement is missing
IAn illegal GO TO or GO SUB target is present (detected during renumbering)

Notable Techniques

  • Machine code embedded in a REM statement at line 10 for compact, single-file distribution.
  • Auto-initialization via a USR call in the program header, eliminating the need for a separate loader step.
  • Use of empty REM statements as lightweight, syntax-neutral delimiters within BASIC source — no special characters or line number conventions are required.
  • Protected user space placement ensures the machine code survives NEW commands issued between the store and insert phases of the merge workflow.

Content

Appears On

Related Products

Utility for the merging and renumbering of Basic programs. Renumbering routine can be used on its own.

Related Articles

Related Content

Image Gallery

Source Code

  10 REM J.C. VAN LEIJDEN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      #)Q▖5▙RNDQ .#[N]74 SAVE 5▙RNDQJ7Q.7QC7Q.7Q 7QV7QA7QN7Q 7QL7QE7QI7QJ7QD7QE7QN5#▌6#RNDTAN                                                                                                                                                                                                    # £$  SAVE "PROGMERG[E]"# ?:  RAND USR 17506#[?]▒CODE   
  20 PRINT "     PROGMERGE VERSIE 004"
  30 PRINT 
  40 PRINT "THIS PROGRAM HAS LOADED MACHINE CODE ROUTINES INTO PROTECTED    USER SPACE. THESE ROUTINES CAN  BE USED TO STORE BASIC PROGRAMS WHOLE OR IN PART. THEY CAN ALSO BE USED TO INSERT THE STORED    MATERIAL INTO ANOTHER BASIC     PROGRAM AND TO RENUMBER THE NEW COMPOSITE PROGRAM."
  50 PRINT "TO STORE PART OF A PROGRAM, PUT EMPTY REM STATEMENTS ON EITHER  SIDE OF THE PART TO BE STORED.  STORE IT USING THE COMMAND:              RAND USR 30000         THEN CLEAR THE PROGRAM FILE WITHNEW."
  60 PRINT AT 21,0;"PROGMERGE TEXT CONTINUES..."
  70 FOR N=1 TO 1000
  80 NEXT N
  90 PRINT AT 21,0;"                                "
 100 FOR N=1 TO 14
 110 SCROLL
 120 NEXT N
 130 PRINT AT 4,0;"LOAD THE SECOND PROGRAM AND MARKTHE PLACE AT WHICH THE INSERTIONIS TO BE MADE WITH ANOTHER EMPTYREM STATEMENT. THE INSERTION CANBE MADE BY THE SAME COMMAND:             RAND USR 30000"
 140 PRINT "THE PROGRAM WILL BE RENUMBERED  AUTOMATICALLY."
 150 PRINT "THE POSSIBLE ERROR MESSAGES ARE:  E IF THERE IS INSUFFICIENT      MEMORY AVAILABLE.               G IF AN EMPTY REM IS  MISSING   I IF AN ILLEGAL GOTO OR GOSUB   IS PRESENT."
 160 PRINT "THE RENUMBERING ROUTINE CAN BE  RUN BY RAND USR 31346."
 170 PRINT "**PROGMERGE UPDATED 02-02-1983**"
 180 PRINT "**COPYRIGHT **J.C. VAN LEIJDEN**"

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

People

No people associated with this content.

Scroll to Top