Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM 



Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\B9\B9\B9\D3\E8\B9\A7\A7 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\B2\B2\A9\A9\BE\BE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"AE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"A itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"A

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\CF\E5E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\E1E\EB\E9A\AF\CBF\CB\CBF\AF\C9

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\AB\D5\E5\EBE\E1EF\EBE\FEA\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\CB\CB\C7\CB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\AF\CBF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\EB\CB\CBF itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\CE\C1\E5\E1\C9

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\FE\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FE\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\FEB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\CB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"AA\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\FA\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
CA\FE\FE\C2\F4A

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
AA\FE\D2\F4\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\DA\F4A\FE\D2\F4\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"DE\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\EF\CD\A7

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
EA\FE\D2\F4F

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\E5AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\F8

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\A7\ED\E1\D2\F4\EDB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\A9\ABAB\CBFE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\AFA\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
AA\C5E\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\F8\C1\CD\B4\CD\F6\CD\CB\E7\AFA\FE\C1\CD\CBF\C0A\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\D8

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9E\D6A\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\D8\B2\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\E5EF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\E5\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"DE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\EF\CD\A7

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\F2\CDE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\EF\CD\A7

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E\E1\A7\ED itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\F3\F2\CD\E1\C1\A3\C5\E5\BA itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\D1\CDAD\C8A\AF\CB\D7\AF\CD\C9\FE\D3\CD\CD\C9\CD\C9\D1\CDAD\C8\CB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AF\CB\D7\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\CD\C9\D9\E5

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\A7\EDA\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\AB\E1\FE\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\CD\CD\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\CD\F0\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\CD\CD\D1 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\CD\C9A\AF\CB\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AB\AD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9\AB\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\CD\BB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\FA\CD\BB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\F7\CD\BDE\CB\D0\CD\CB itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\CB\A7\AFA\B4\CD\F6

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9\AB\CD\CB\AF\CBFA\D0\D6A\D0\D0\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\ED\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AD\EB\A7\EDFEA\D0

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FE\EDB\A9

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AB\A7\ED\EE\CD\CB\CF\CB\DF\AF\D2\CD\ED\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E\FEA\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"\CCA\AF\CBF\CB\AF\AFE\CB\EF\AFEA\D1\EDB\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\A9

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9\A7\ED\F6A\D0\FE\B0A\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\CB\AF\AFE\D1\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\CBF\CA

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\B4\CD\CD\F6\B2\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FE\E3\CD\BB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\FAA\AF\CBF\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
FE\D1\CF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FEA\FE\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\FE\FE\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\ABA\AF\CBE\D6A\AF\CBF\B0\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
AE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\EB\C2\CD\F6\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
F\CD\BB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\FAA\AF\CBF\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
FE\D1A\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\C8\FEA\CD\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9\CD\C9\C5\D5\F2\ED\AB\CD\E5A\F2\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"DE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\CD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\EF\CD\A7

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
EA\F3\D6 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"CF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\D1\E1\C1\C8\C5\E5\EB\CC\F0A\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4" itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\EDB\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AD\A7\ED\C8\D8A\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\CD

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\CB\D7\AF\EB\CD\C9A\FEA\A7\CBA\AF\E0\CB\CF\CB\DF\D5\E5\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AB

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
B\EDB\AD itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\ED\AB\CD\E1\D1A\AF\C0\EDB\A9

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\AB\A7\ED

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\EDB\A9\ED\AB\C2\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
EA\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\CB\C1 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"A\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"C\CB\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
D\FE\FE itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"B\CB\CB\C9 itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-56710 wp-custom-logo wp-embed-responsive wp-theme-astra wp-child-theme-astra-child ast-desktop ast-separate-container ast-left-sidebar astra-4.12.6 group-blog ast-blog-single-style-1 ast-custom-post-type ast-single-post ast-inherit-site-logo-transparent ast-hfb-header ast-full-width-primary-header ast-box-layout ast-normal-title-enabled astra-addon-4.12.4"D\E1

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9\AB\B0\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
C\FE\EBA\AF\CB\AF\C3A\AF\CBE\C2\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
\C4\C3

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\A9E\FE

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
A\FEE\FE\CD\CB\D7\AF

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top

Screen Machine

Products: Screen Machine
Date: 1983
Type: Cassette
Platform(s): TS 1000

Machine language sub-routine that allows inputs anywhere on screen, complete error checking, automatic formatting (dates, decimals), and advance directly to next prompt.


Program Analysis

This program implements a data entry routine, using an embedded machine code routine stored in a REM statement at line 1. The machine code begins at address 16384 (0x4000) and is invoked via RAND USR 16729, handling screen and keyboard input operations. The BASIC shell (lines 10–25) acts as a wrapper, using PEEK and POKE at addresses 16514–16520 to pass parameters to and from the machine code, including a string P$ for control parameters and Q$ for data. The routine includes logic for a “V” mode (line 21) that skips writing results back to Q$, suggesting a verify or view-only pass.

Program Structure

The program is organized into two distinct layers. The BASIC shell occupies lines 1–100, while the heavy lifting is performed by Z80 machine code embedded in the REM statement at line 1. Line 9 uses the GO TO VAL "100" idiom to jump past the data and REM metadata to the actual program entry point. Lines 10–29 form a subroutine (returned from at line 29) that acts as the interface between BASIC and the machine code.

REM-Embedded Machine Code

Line 1’s REM statement contains several hundred bytes of Z80 machine code. Because the Spectrum/TS2068 BASIC system stores the REM text starting at a known offset into the program area, the machine code lands at a predictable address in RAM. The entry point is called via RAND USR 16729 at line 20, placing the start of executable code at address 16729 (0x4179) within the block. Line 2 contains a short secondary REM, likely acting as padding or a data table.

Parameter Passing Convention

The BASIC wrapper communicates with the machine code through a set of fixed memory locations POKEd before the RAND USR call:

  • POKE 16514, CODE P$(1) — passes the first character of the control string as a command byte.
  • POKE 16515, VAL P$(2) — passes a numeric sub-parameter.
  • Lines 14–16 (FOR Q=2 TO 5) pack additional two-character numeric fields from P$ into addresses 16516–16519.
  • Lines 17–19 copy up to PEEK 16519 characters from Q$ (offset by PEEK 16518) into addresses starting at 16521, providing the data buffer.

After the machine code returns, lines 22–24 read the (possibly modified) buffer back into Q$, closing the round-trip data exchange.

Notable BASIC Techniques

  • VAL for line numbers: GO TO VAL "100" at line 9 is a memory-saving technique; storing the target as a string constant avoids the five-byte floating-point number representation.
  • Conditional skip on “V” mode: Line 21 checks P$(1)="V" and jumps to line 25, bypassing the write-back loop (lines 22–24). This implements a view/verify mode where the buffer is not flushed back to Q$.
  • Null-guard on P$(2): Line 12 replaces a space in P$(2) with "0" before calling VAL, preventing a runtime error on an empty field.
  • PEEK 16520 result read-back: Line 25 (LET Q=PEEK 16520) retrieves a return value left by the machine code in the data buffer area.

Machine Code Overview

The Z80 code is extensive (over 400 bytes). Key patterns visible in the hex dump include:

  • Frequent use of ED 42 / ED 52 (SBC HL,BC / SBC HL,DE) for 16-bit arithmetic, suggesting cursor position or string length calculations.
  • CD BB 02 — repeated calls to address 0x02BB, which is the TS2068/Spectrum ROM routine for scanning the keyboard.
  • CD 2B 0F — calls to 0x0F2B, the ROM’s “wait for keypress” or display routine.
  • EF bytes — RST 0x28, the floating-point calculator, used for numeric display formatting.
  • A jump table near the start of the code (based on the series of FE xx 28 yy sequences) dispatches on the command byte stored at 0x4082, handling command codes including 0x0A, 0x08, 0x06, 0x33, 0x38, 0x29, 0x28, and 0x3B.

Address Map

AddressRole
0x4000 (16384)Start of REM machine code block
0x4082 (16514)Command byte (from P$(1))
0x4083 (16515)Sub-parameter 1
0x4084–0x4087Additional parameters from P$(4..10)
0x4088 (16520)Data buffer start / return value
0x4179 (16729)Machine code entry point (RAND USR target)

Metadata and Provenance

REM statements at lines 91–96 identify the routine as SCREEN / 2D.02 / 3140, copyright 1983 by Management Services Co. This version/build numbering suggests the machine code was part of a larger commercial library of data entry utilities distributed as BASIC programs with embedded Z80 routines.

Content

Appears On

Related Products

Program inputs like on mainframe computers. 1K machine language sub-routine allows inputs anywhere on screen, complete error checking, automatic formatting...

Related Articles

Related Content

Image Gallery

Screen Machine

Source Code

   1 REM \00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\1B\42\64\43\B9\42\B9\42\B9\42\D3\42\E8\42\03\43\B9\42\46\45\A7\45\46\45\A7\45\1D\46\28\46\46\45\00\88\80\B2\B2\A9\A9\BE\BE\28\34\37\37\2A\28\39\0F\00\10\33\1A\3E\1A\33\1A\29\11\0E\18\0D\1B\1C\00\16\1C\1D\CF\18\E5\21\82\40\7E\16\00\5F\E1\19\5E\23\56\EB\E9\3A\AF\40\CB\8F\CB\97\CB\9F\32\AF\40\C9\06\02\11\AB\40\D5\E5\EB\5E\23\56\E1\7E\4F\EB\7E\FE\76\3A\AF\40\20\0F\CB\47\20\05\CB\C7\23\18\03\CB\87\2B\32\AF\40\71\CB\4F\20\03\23\18\01\2B\EB\CB\57\20\08\CB\5F\20\03\23\18\01\2B\10\CE\C1\E5\60\69\73\23\72\E1\C9\21\82\40\06\00\3A\82\40\FE\38\28\22\FE\33\28\1B\00\00\28\16\FE\29\28\11\FE\28\28\0C\FE\3B\28\07\00\00\00\00\18\08\04\04\04\04\04\04\CB\00\70\78\FE\0A\20\1A\06\03\21\85\40\3A\83\40\FE\03\30\04\0E\17\18\02\0E\18\71\0E\01\23\10\FA\18\10\FE\06\20\0C\3A\87\40\FE\04\28\05\FE\06\C2\F4\40\21\5A\00\22\23\40\22\0A\40\3A\87\40\FE\21\D2\F4\40\FE\01\DA\F4\40\3A\84\40\FE\17\D2\F4\40\CD\1D\15\3E\21\CD\1D\15\EF\04\34\CD\A7\0E\03\3A\85\40\FE\20\D2\F4\40\6F\26\00\09\E5\3A\87\40\4F\06\00\09\01\F8\02\A7\ED\42\E1\D2\F4\40\ED\4B\0C\40\09\22\A9\40\22\AB\40\3A\3B\40\CB\7F\3E\80\20\02\3E\00\32\AF\40\3A\82\40\FE\0A\28\11\3A\87\40\47\C5\21\89\40\7E\FE\01\30\0F\23\10\F8\C1\CD\05\41\21\B4\40\CD\F6\40\18\28\CD\05\41\CB\E7\32\AF\40\21\89\40\3A\82\40\FE\08\28\22\C1\CD\14\41\CB\6F\C0\3A\83\40\D6\01\D8\2A\A9\40\7E\D6\80\77\18\06\3A\83\40\D6\01\D8\21\B2\40\C3\00\41\E5\7E\6F\26\00\E5\CD\1D\15\3E\0A\CD\1D\15\EF\05\24\34\CD\A7\0E\21\1C\00\09\7D\32\F2\40\CD\20\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\E1\A7\ED\42\01\1C\00\09\7D\32\F3\40\21\F2\40\CD\12\41\E1\C1\05\28\A3\C5\23\E5\18\BA\06\01\21\D1\40\CD\14\41\3A\87\40\3D\C8\47\3A\AF\40\CB\D7\32\AF\40\CD\14\41\C9\78\FE\04\21\D3\40\20\09\CD\12\41\23\23\CD\12\41\C9\CD\14\41\C9\21\D1\40\CD\12\41\3A\87\40\3D\C8\47\CB\00\3A\AF\40\CB\D7\32\AF\40\2B\CD\14\41\C9\21\D9\40\E5\2A\AB\40\06\00\0E\0F\A7\ED\42\3A\83\40\FE\03\38\02\2B\2B\22\AB\40\E1\FE\03\30\20\FE\01\20\13\06\0A\CD\14\41\06\03\23\23\CD\14\41\23\23\CD\12\41\18\22\06\0D\CD\14\41\23\23\18\F0\FE\03\20\09\06\0A\CD\14\41\06\07\18\07\06\0D\CD\14\41\06\04\23\23\CD\14\41\21\D1\40\06\01\CD\14\41\C9\3A\AF\40\CB\87\32\AF\40\2A\AB\40\22\AD\40\2A\A9\40\22\AB\40\CD\2B\0F\CD\BB\02\2C\20\FA\CD\BB\02\44\4D\51\14\28\F7\CD\BD\07\7E\CB\77\32\D0\40\20\50\CD\05\41\CB\67\28\1D\CB\A7\32\AF\40\3A\87\40\47\21\B4\40\CD\F6\40\2A\A9\40\22\AB\40\CD\05\41\CB\87\32\AF\40\CB\6F\28\07\3A\D0\40\D6\80\18\03\3A\D0\40\21\D0\40\77\CD\12\41\1B\ED\53\AB\40\2A\AD\40\EB\A7\ED\52\38\9F\3E\7A\32\D0\40\18\02\18\96\FE\77\20\23\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\EE\CD\05\41\CB\CF\CB\DF\32\AF\40\21\D2\40\CD\12\41\13\ED\53\AB\40\18\2E\FE\74\20\60\3A\82\40\FE\01\30\CC\3A\AF\40\CB\6F\28\09\CB\AF\32\AF\40\3E\88\18\07\CB\EF\32\AF\40\3E\8A\32\D1\40\ED\5B\AB\40\12\18\02\18\A9\2A\A9\40\A7\ED\52\38\F6\3A\D0\40\FE\74\21\B0\40\3A\AF\40\28\0D\CB\AF\32\AF\40\3E\88\32\D1\40\C3\00\41\CB\6F\CA\00\41\21\B4\40\CD\05\41\CD\F6\40\21\B2\40\C3\00\41\FE\E3\20\17\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\CF\0C\06\00\FE\7A\28\18\FE\76\28\14\FE\73\28\0F\FE\70\28\0A\FE\71\28\05\FE\72\20\93\04\04\04\04\78\32\88\40\CD\23\0F\2A\AB\40\3A\AF\40\CB\67\28\13\7E\D6\80\77\3A\AF\40\CB\6F\28\12\21\B0\40\CD\00\41\18\0A\3E\00\77\EB\21\C2\40\CD\F6\40\CD\2B\0F\CD\BB\02\2C\20\FA\3A\AF\40\CB\7F\20\03\CD\23\0F\3E\88\32\D1\40\3A\82\40\FE\0A\C8\FE\08\3A\87\40\47\CD\05\41\21\89\40\22\AB\40\2A\A9\40\28\04\CD\14\41\C9\C5\11\89\40\D5\11\F2\40\ED\53\AB\40\CD\12\41\E5\3A\F2\40\D6\1C\CD\1D\15\3E\0A\CD\1D\15\EF\04\34\CD\A7\0E\3A\F3\40\D6\1C\6F\26\00\09\7D\D1\E1\C1\77\05\C8\23\C5\E5\EB\18\CC\11\F0\40\3A\82\40\FE\08\20\01\1B\ED\4B\AB\40\2A\AD\40\A7\ED\42\C8\D8\3A\83\40\FE\02\CD\05\41\28\0B\CB\D7\32\AF\40\45\EB\CD\14\41\C9\3A\82\40\FE\08\3A\87\40\20\03\A7\CB\07\45\90\47\3A\AF\40\28\E0\CB\CF\CB\DF\D5\E5\32\AF\40\2A\AB\40\2B\ED\5B\AD\40\1B\ED\53\AB\40\CD\14\41\E1\D1\3A\AF\40\18\C0\ED\5B\A9\40\2A\AB\40\A7\ED\52\28\02\30\12\3E\1C\ED\5B\A9\40\12\13\ED\53\AB\40\21\C2\40\C3\00\41\45\0E\04\3A\82\40\FE\02\28\02\CB\C1\1A\FE\1C\30\25\CB\41\20\14\FE\01\38\2D\FE\16\28\29\FE\1B\20\08\CB\49\20\04\CB\C9\18\1D\E1\2A\A9\40\22\AB\40\21\B0\40\C3\00\41\FE\76\28\0C\FE\26\30\EB\3A\AF\40\CB\91\32\AF\40\13\10\C3\3A\AF\40\CB\51\20\9E\21\C2\40\C3\00\41\3E\02\32\83\40\21\C4\40\C3\00\41\06\07\2A\A9\40\7E\FE\33\28\0A\FE\3E\28\05\FE\29\20\06\04\04\78\32\88\40\CD\05\41\CB\D7\32\AF\40\06\00\0E\11\A7\ED\42\22\AB\40\06\12\21\F0\40\CD\14\41\C9\24\25\21
   2 REM 
   9 GOTO VAL "100"
  10 REM ** SCREEN **
  11 POKE 16514,CODE P$(1)
  12 IF P$(2)=" " THEN LET P$(2)="0"
  13 POKE 16515,VAL P$(2)
  14 FOR Q=2 TO 5
  15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q)
  16 NEXT Q
  17 FOR Q=1 TO PEEK 16519
  18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1)
  19 NEXT Q
  20 RAND USR 16729
  21 IF P$(1)="V" THEN GOTO VAL "25"
  22 FOR Q=1 TO PEEK 16519
  23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520)
  24 NEXT Q
  25 LET Q=PEEK 16520
  29 RETURN 
  90 REM DATA ENTRY ROUTINE
  91 REM SCREEN / 2D.02 / 3140   
  95 REM COPYRIGHT (C) 1983 BY:
  96 REM MANAGEMENT SERVICES CO. 
 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top
E\A7\ED\AB\F0\CD\C9 2 REM 9 GOTO VAL "100" 10 REM ** SCREEN ** 11 POKE 16514,CODE P$(1) 12 IF P$(2)=" " THEN LET P$(2)="0" 13 POKE 16515,VAL P$(2) 14 FOR Q=2 TO 5 15 POKE 16514+Q,VAL P$(2*Q-1 TO 2*Q) 16 NEXT Q 17 FOR Q=1 TO PEEK 16519 18 POKE 16520+Q,CODE Q$(Q+PEEK 16518-1) 19 NEXT Q 20 RAND USR 16729 21 IF P$(1)="V" THEN GOTO VAL "25" 22 FOR Q=1 TO PEEK 16519 23 LET Q$(Q+PEEK 16518-1)=CHR$ PEEK (Q+16520) 24 NEXT Q 25 LET Q=PEEK 16520 29 RETURN 90 REM DATA ENTRY ROUTINE 91 REM SCREEN / 2D.02 / 3140 95 REM COPYRIGHT (C) 1983 BY: 96 REM MANAGEMENT SERVICES CO. 100 REM ** START PROGRAM HERE

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

People

No people associated with this content.

Scroll to Top