RAMPAGE-R is a machine-code-driven RAM text editor that loads and runs a substantial Z80 routine embedded in the REM statement at line 1. The program displays a title screen rendered in block graphics alongside a command reference listing read/write operations such as address jump, page navigation, copy, insert, and kill. After the user presses ENTER, control is transferred to the machine code via RAND USR 30720 (line 250). A separate save routine at line 1000 uses RAND USR 16526 to invoke the system’s SAVE entry point, preserving the program including its embedded binary payload. The REM block at line 1 contains several hundred bytes of Z80 machine code that implements the full editor logic, including keyboard scanning, screen memory manipulation, and cursor movement.
Program Analysis
Program Structure
The listing divides into two functional blocks:
- Lines 1–260: Title/splash screen, command reference, and launch sequence.
- Lines 1000–1030: A self-save utility that preserves the program (including machine code) back to tape.
Line 1 is a REM statement whose body is not human-readable text but rather a dense stream of Z80 opcodes. The BASIC portion is purely a loader/UI shell; every meaningful operation of the editor is performed by the machine code.
Machine Code Payload
The REM at line 1 contains several hundred bytes of Z80 machine code. The entry point is reached by RAND USR 30720 at line 250. The hex address 30720 (0x7800) places the entry inside the REM body, which in a 16 KB RAM machine sits in a predictable location given a freshly loaded program.
Significant Z80 patterns visible in the payload include:
ED B0—LDIRblock-copy instructions, used for moving screen data and initialising memory regions.ED 42/ED 52—SBC HL,BC/SBC HL,DE, used for 16-bit comparisons to determine cursor position boundaries and direction.CD BB 02— repeatedCALL 0x02BB, the ROM keyboard-scan routine that returns a key row/column result; used throughout the main edit loop for polled input.CD BD 07—CALL 0x07BD, the ROM routine that converts a character address to a display-file address.CD 1C 7A— an internal subroutine (within the REM body) called repeatedly; likely the routine that writes nibble-encoded characters to the display file.- Structured
CALL cc / JP ccchains implementing a multi-key dispatch table for the editor commands (A, 6, 7, Z, W, L, S6, S7, I, K). CB 44,CB 5D,CB 65—BITtests on B and E registers, used to decode the two-byte keyboard port result into individual key states.
Title Screen Rendering
Lines 20–40 use zmakebas block-graphic escape sequences to draw a decorative logo in the BASIC PRINT statements. The logo is composed entirely of the eight 2×2 block characters (codes 128–135), requiring no UDG definitions or machine code for the title art.
Line 100 uses inverse-video characters (percent-encoded as %R%A%M%P%A%G%E%R etc.) to render the heading “RAMPAGE-R COMMAND LIST” with alternating highlighted letters, a common Sinclair BASIC display technique.
Lines 120 uses repeated \~~ sequences (inverse tilde / pound-sign characters) to draw separator lines, producing a ruled appearance.
Command Reference Table
The on-screen command list documents the following editor operations:
| Mode | Key | Function |
|---|---|---|
| Read | A | Address (jump to address) |
| Read | 6 | Next page |
| Read | 7 | Last page |
| Read | Z | Copy |
| Read | W | Write (enter write mode) |
| Write | L | Last (go to last) |
| Write | S6 | Scroll down |
| Write | S7 | Scroll up |
| Write | I | Insert |
| Write | K | Kill (delete) |
| Both | ENTER | Return to Read mode |
| Both | BREAK | Return to BASIC |
Input Handling (BASIC side)
Line 230 implements a busy-wait on INKEY$ comparing against CHR$ 118 (the ENTER key, character code 0x76 in the Sinclair character set) before launching the machine code. This is the standard BASIC polling idiom for waiting on a specific keypress without halting execution.
Save Routine
Lines 1000–1030 constitute a self-contained save block. RAND USR 16526 at line 1020 calls the ROM SAVE entry point (address 0x408E / 16526), causing the entire BASIC program — including the REM-embedded machine code — to be saved to tape under the name RAMPAGE-R (rendered with inverse R via %R). After saving, RUN at line 1030 restarts the program from line 1, returning to the splash screen.
Memory Map Observations
Several 16-bit addresses appear repeatedly in the machine code as operands to LD HL,(nn), LD (nn),HL, and LD DE,(nn):
0x400C— likely the PROG/E-LINE system variable area, used to locate the start of the BASIC program in RAM.0x407B— an internal workspace variable storing the current editor cursor or buffer pointer.0x403C/0x403E/0x4036— additional editor state variables (page start, write position, etc.).0x400E— a further pointer, possibly the current line pointer within the editor buffer.
The machine code performs arithmetic on these pointers (adding fixed offsets like +5, +0x10, +0x13, +0x17, +0x18) consistent with navigating a fixed-width screen of 24 lines × 33 columns, matching the ZX81/TS1000 32-column display with a one-byte attribute or end marker.
Notable Techniques
- The entire editor binary is self-contained in a
REMline, requiring no separate code loading; the BASIC program is the binary. - The use of
RAND USR(rather thanGO TOorGOTO) to invoke machine code is idiomatic: it discards the USR return value silently and avoids needing a variable assignment. - Keyboard scanning via direct
CALL 0x02BB(ROM KEYBOARD) is more responsive than BASICINKEY$and allows multi-key combinations (e.g. SHIFT+6 for S6, SHIFT+7 for S7). - The
LDIRinstruction is used for both bulk memory initialisation and text scrolling, avoiding slow byte-by-byte BASIC loops. - The copyright notice (line 70) credits Dan Tandberg, MD of Calliope Software, Albuquerque, New Mexico, 1983.
Content
Source Code
1 REM B37263235262C2A37 B767621824011DF77 123 5EDB021 07822 440CD9614C9FD3622 02A C4023CD2679227B40CDB379CD2E7ACDBB 2 1FEFBAFE5ED42E120 3CDFB7C 1EFDFAFE5ED42CCE77AE1 1EFEFAFE5ED42CC287BE1 17FFDAFE5ED42E1C8 1FDFDAFE5ED42E128B7 1FBFBAFE5ED42E120BD2A C401110 019223C407EC680772A7B40223E402A C40111B 0193EB177233EA677233EB877233EB977233E9477CD707BCDBB 2 1BFFDAFE5ED42E1CA E78 17FFDAFE5ED42E1C8 1BFFBAFE5ED42CC8D7BE1 1EFDEAFE5ED42CCA47BE1 1EFEEAFE5ED42CCD77BE1 1DFF7AFE5ED42CC 17CE1 1BFF7AFE5ED42CC287CE1CB4428AECB5D2843CB65283F 1FDFDAFE5ED42E12835 17FDFAFE5ED42E1282B 1FEEFAFE5ED42E12821 1FDF7AFE5ED42E12817 1FBF7AFE5ED42E128 D 1FDEFAFE5ED42E128 3C38878C34F7C 0 0E53EA677233EA977233EA977233EB777233E8F77E1 6 5C5E5CDBB 27CFEFF28F8CB4728F47DCB5F28 4CB6720EB444DCDBD 77EE177E5CDBB 27DFEFF20F8E123C110D3 6 52B7ED61CF510F921 0 0111027F147FE 028 31910FD11E8 3F147FE 028 31910FD1164 0F147FE 028 31910FD11 A 0F147FE 028 31910FD11 1 0F147FE 028 31910FDC92A C4011 5 019E5 617C5E5E51121 019EBE1D5 1 5 0EDB8E17EFE7628 B3CFE2620 5361C2B18F177E11121 019C110D8E12323ED4B7B4078CD1C7A2379CD1C7A 617C5E5E51121 019EBE1D5 1 4 0EDB8E17E3CFE2C20 5361C2B18F577E11121 019C110DCC9F5E6F0 F F F FC61C7723F1E6 FC61C77C9ED4B7B402A C4011 C 019D5C5E53E1C77237723772B2B AA7D66438 7F57E3C77F118F5C664A723D6 A38 7F57E3C77F118F5C6 AA723D6 138 7F57E3C77F118F5E11121 019C1 3D1147AFE1828 218B92A C401110 019ED5B7B40 618D5E51ACD1C7AE11121 019D11310F1ED4B7B402A C401113 019D5C5E5C5AF 6 6772310FCC1E122 E40 AFEC038 DFEC32819FDCB 1C6CD4B 91810FE4038 8FE4338EFFE8038 42A E40771121 019C1 3D1147AFE1820C1C92A C4011FC 219 6 57EF52B10FB2A C4023 6 5F1772310FB7EFE 020 32B18F8FE7628 B3CFE2620 5361C2B18EA772A7B401118 019227B40CDB379CD2E7AC92A C4011 5 019E5ED5B7B40 6181BE57EFE 020 32B18F8FE7628 B3DFE1B20 536252B18EA77E110E4ED537B40E1 6 57EF52B10FB2A C4023 6 5F1772310FBCDB379CD2E7AC9 11A 1CDF5 8ED5B E4021 01E 1 5 0EDB0ED4B3640CD2015CD55 BC92A C40113C 019CD2679223640C9CDBB 27DFEFF20F8C92A7B401117 019ED5B3E40AFED5220 6CDE77AC357782A3C407EC680771121 019223C407EC680772A3E4023223E40CD9B7BC92A7B40ED5B3E40AFED52C82A3C407EC680771121 0AFED52223C407EC680772A3E402B223E40CD9B7BC92A3640ED5B3E40AFED52D8444D2A3640545D2BEDB82A3E4077CD2E7A2A3C407EC68077CD9B7BC92A3640ED5B3E40AFED52D8444D2A3E40545D23EDB02A364077CD2E7A2A3C407EC68077CD9B7BC9444DCDBD 77E2A3C4077D61C 7 7 7 7F5237EC68077E5CD9B7BCDBB 2CB4428F9CB5D2843CB65283F 1FDFDAFE5ED42E12835 17FDFAFE5ED42E1282B 1FEEFAFE5ED42E12821 1FDF7AFE5ED42E12817 1FBF7AFE5ED42E128 D 1FDEFAFE5ED42E128 318B3 0444DCDBD 77EE177D61CC1802A3E4077CD2E7A2A7B401117 019ED5B3E40AFED5220 6CDE77AC357782A3E4023223E402A3C401121 019223C407EC68077CD9B7BC388781618C36B 8 0 0
20 PRINT " ' ' :'''. .''. :. .: :''. .''. .''. :''' :'''. ' '"
30 PRINT " :...' :..: : ' : :..' :..: : .. :.. :...'"
40 PRINT " : '. : : : : : : : '..' :... : '."
50 PRINT
60 PRINT " COPYRIGHT 1983"
70 PRINT " DAN TANDBERG, MD"
80 PRINT " CALLIOPE SOFTWARE"
90 PRINT " ALBUQUERQUE, NEW MEXICO",,,
100 PRINT "% % % % % % %R%A%M%P%A%G%E%R% %C%O%M%M%A%N%D% %L%I%S%T% % % % % "
110 PRINT " READ: WRITE:"
120 PRINT " ~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~"
130 PRINT " A ADDRESS L LAST"
140 PRINT " 6 NEXT PAGE S6 DOWN"
150 PRINT " 7 LAST PAGE S7 UP"
160 PRINT " Z COPY I INSERT"
170 PRINT " W WRITE K KILL"
180 PRINT
190 PRINT " ENTER: RETURN TO READ"
200 PRINT " BREAK: RETURN TO BASIC"
210 PRINT "================================"
220 PRINT " (PRESS ENTER TO BEGIN)"
230 IF INKEY$<>CHR$ 118 THEN GOTO 230
240 CLS
250 RAND USR 30720
260 STOP
1000 REM % %S%A%V%E% %R%O%U%T%I%N%E%
1010 SAVE "RAMPAGE%R"
1020 RAND USR 16526
1030 RUN
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

