--- title: "Tape to Tape Backup" id: 56321 type: "computer_media" slug: "tape-to-tape-backup" url: "http://localhost/computer_media/tape-to-tape-backup/" markdown_url: "http://localhost/computer_media/tape-to-tape-backup.md" published_at: "2024-08-04T10:50:00+00:00" modified_at: "2026-03-31T22:29:51+00:00" author: "David Anderson" featured_image: url: "http://localhost/wp-content/uploads/2024/08/SCR-20240803-johr.png" excerpt: "A clever 20-byte machine code routine turns the computer into a live tape signal relay, letting you duplicate cassettes with just two recorders." category: - name: "Archived Media" slug: "archived-media" taxonomy: "category" url: "http://localhost/category/archived-media/" post_tag: - name: "Downloadable" slug: "downloadable" taxonomy: "post_tag" url: "http://localhost/tag/downloadable/" - name: "TS 2068" slug: "ts2068" taxonomy: "post_tag" url: "http://localhost/tag/ts2068/" model: - name: "Timex/Sinclair 2068" slug: "ts-2068" taxonomy: "model" url: "http://localhost/model/ts-2068/" indiv: - name: "Larry Kenny" slug: "larry-kenny" taxonomy: "indiv" url: "http://localhost/indiv/larry-kenny/" genre: - name: "Tape" slug: "tape" taxonomy: "genre" url: "http://localhost/type/tape/" media_contents: - id: 56277 title: "Timex Sinclair Public Domain Library Tape 2001" type: "computer_media" url: "http://localhost/computer_media/timex-sinclair-public-domain-library-tape-2001/" media_type: "Program" programmers: - name: "Larry Kenny" slug: "larry-kenny" taxonomy: "indiv" url: "http://localhost/indiv/larry-kenny/" download_url: "https://archive.org/download/timex-sinclair-software-archive/Tape%20to%20Tape%20Backup%20%281986%29%28Kenny%2C%20Larry%29%28TS2068%29%28CA%29%28Program%29.zip" mediadate: "1986" producer_company: - id: 11042 title: "LARKEN Electronics" type: "company" url: "http://localhost/company/larken-electronics/" images: - url: "http://localhost/wp-content/uploads/2024/08/SCR-20240803-johr.png" article_media: - id: 16090 title: "Tape Backup" type: "article" url: "http://localhost/article/tape-backup/" media_type_tags: "Tape" --- # Tape to Tape Backup This program implements a tape-to-tape backup utility that uses the TS2068 as a signal reconditioner between two cassette recorders. A 20-byte machine code routine is loaded into RAM at address 60000 via POKE and executed with RANDOMIZE USR. The machine code reads the EAR port (IN 254), extracts the tape signal bit, and re-outputs it to the MIC port (OUT 254), effectively relaying the audio signal in real time. The user is instructed to connect the original tape deck to the EAR input and the backup recorder to the MIC output, adjusting playback volume to minimise border interference during silent sections. *** ## Program Analysis ### Program Structure The program is organised into three phases: machine code loading (lines 10–30), user instructions (lines 35–60), and execution (line 70). The `DATA` statement at line 100 holds the 20-byte machine code payload. Line 10 uses `CLEAR 60000` to protect the target memory area from BASIC, and the `FOR` loop at lines 20–30 POKEs each byte into place before clearing the screen and printing instructions. ### Machine Code Routine The 20 bytes at address 60000 form a tight real-time relay loop. Disassembling the `DATA` values: 1. `243` — DI (disable interrupts, preventing interference during tight loop) 2. `219, 254` — IN A,(254) — read the keyboard/EAR port 3. `31` — RRA (rotate right through carry) 4. `31` — RRA 5. `31` — RRA (three rotations shift bit 6, the EAR bit, into the carry flag area) 6. `48, 10` — JR NC, +10 (jump forward if carry clear — signal low) 7. `203, 95` — BIT 3,L (tests a register bit — used here as a timing/filler instruction) 8. `40, 2` — JR Z, +2 (conditional branch) 9. `246, 4` — OR 4 — set bit 2 (MIC bit) in accumulator 10. `211, 254` — OUT (254),A — write to the border/MIC port 11. `24, 239` — JR -17 (loop back to the IN instruction — offset 239 = -17 signed) 12. `251` — EI (re-enable interrupts — reached only on exit) 13. `201` — RET The routine continuously samples the EAR input and drives the MIC output accordingly, acting as a hardware-level signal relay. Interrupts are disabled for the duration via `DI` to ensure timing consistency; `EI` and `RET` at the end cleanly return control to BASIC, though in normal operation the loop is exited only if the author intended a specific break condition (the `JR NC` path does not output and loops back, while the taken path outputs the MIC bit). ### Key BASIC Idioms - `CLEAR 60000` — sets RAMTOP below the machine code area, protecting it from BASIC’s memory allocation. - `RANDOMIZE USR 60000` — standard idiom for calling a machine code subroutine; the return value from `USR` is discarded by `RANDOMIZE`. - The `FOR`/`READ`/`POKE`/`NEXT` pattern (lines 20–30) is the canonical self-installing machine code loader in Sinclair BASIC. ### Relocatability The REM header at line 4 notes the routine is relocatable. Inspection confirms this: the machine code contains only relative jumps (`JR`) and I/O instructions with fixed port numbers. There are no absolute `JP` or `CALL` instructions, so the 20-byte block can be POKEd to any address and called with the corresponding `USR` value without modification. ### Hardware Usage | Port | Direction | Purpose | | --- | --- | --- | | 254 (0xFE) IN | Read | EAR input — tape signal from original cassette deck | | 254 (0xFE) OUT | Write | MIC/border output — relayed signal to backup recorder | Both input and output share port 254, which is the standard ULA port. Bit 6 of the read value carries the EAR signal; bit 2 of the write value drives the MIC output. The border colour bits are also affected by the OUT instruction, which is why the user is advised to adjust volume to minimise border flickering during silent tape sections. ### Notable Techniques - Disabling interrupts ensures the relay loop runs without the 50 Hz interrupt breaking the timing, which could cause dropout artefacts in the copied signal. - The use of three consecutive `RRA` instructions to extract the EAR bit is an efficient alternative to masking with `AND`. - The tight 10-instruction loop minimises latency between sampling and output, which is critical for accurate waveform reproduction. ## Source Code ``` 1 REM "Tape to Tape Backup" 2 REM By Larry Kenny 3 REM SUM Magazine June 1986 4 REM Routine is relocateable 10 CLEAR 60000 20 FOR a=60000 TO 60019 25 READ x: POKE a,x 30 NEXT a: CLS 35 PRINT : PRINT "Tape to Tape Backup by Larry Kenny of Larken Electronic" 40 PRINT : PRINT " This program is for making tape to tape copies using the 2068 as a signal reconditioner": PRINT 50 PRINT " Using 2 tape recorders, play the original tape into the input of the 2068 (ear) and record your backup tape from the output of the 2068 (mic). Adjust the play volume so the border doesn't flicker too much on the silent periods of the tape." 60 PRINT : PRINT " Rewind both tape recorders andstart them both at the same time",,"TYPE 3 to stop" 70 RANDOMIZE USR 60000 100 DATA 243,219,254,31,31,31,48,10,203,95,40,2,246,4,211,254,24,239,251,201 ```