Merry Christmas Message

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Holiday

This program displays a “MERRY CHRISTMAS” greeting using a machine code routine embedded in a REM statement at line 1. The machine code, stored from address 16514 onward, is a Z80 routine that manipulates the display — it uses register pairs and relative jumps (DJNZ loops) to write directly to screen memory. Lines 3 and 5 use POKE 16515 to modify a byte within the REM/machine code area itself, effectively self-modifying the routine’s behaviour between two calls via RAND USR 16514. The PRINT AT statement at line 8 positions the greeting text at row 10, column 8, and the GOTO 2 loop continuously cycles the display effect.


Program Analysis

Program Structure

The program is short but layered. Line 1 holds a REM statement whose body is raw Z80 machine code. Lines 2–6 form the main execution loop: call the machine code routine, poke a new value into it, call it again with the modified byte, then repeat forever via GOTO 2. Line 7 is a SAVE command that would save the program. Line 8 prints the greeting, and line 9 loops back — though line 8 and 9 are never reached by the main loop at line 6, suggesting the program was perhaps edited or the loop is intended to cycle only through lines 2–6.

Machine Code in the REM Statement

On the ZX81/TS1000, a REM statement’s text bytes begin at address 16514 (the byte immediately after the line-length and REM token). The bytes stored there are:

OffsetHexZ80 MnemonicNotes
03E 86LD A, 86hLoad accumulator with 134
22A 0C 40LD HL, (400Ch)Load HL from display address area
506 20LD B, 32Counter for 32 bytes
723INC HLAdvance pointer
877LD (HL), AWrite A to screen memory
910 FCDJNZ -4Loop 32 times
1106 14LD B, 20Counter for 20 rows
1323 23INC HL / INC HLSkip two bytes
1577LD (HL), AWrite pattern
1611 1F 00LD DE, 31Row stride
1919ADD HL, DEAdvance by one row
2077LD (HL), AWrite pattern
2110 F6DJNZ -10Loop 20 rows
2323INC HL
2406 20LD B, 32Counter for 32 bytes
2623INC HL
2777LD (HL), AWrite pattern
2810 FCDJNZ -4Loop 32 times
30C9RETReturn to BASIC

The routine draws a rectangular border pattern around the screen by writing the value in the accumulator to a run of display file bytes. The first call (line 2) uses whatever byte is currently at offset 1 of the REM (initially 86h = 134, a ZX81 graphics character). Line 3 then POKEs address 16515 (offset 1, the immediate operand of LD A, n) to 6, changing the character written. Line 4 calls the routine again with this new value, creating an animation toggle effect.

Self-Modification Technique

The key idiom here is patching the machine code’s own immediate operand through POKE 16515. Because the LD A, n instruction’s operand sits at a known, fixed address within the REM statement, lines 3 and 5 alternate the value between 6 and 134 (decimal), causing the border pattern to flash between two different graphic characters on each loop iteration. This is a classic ZX81 self-modifying code pattern used to squeeze animation out of minimal ROM calls.

Key BASIC Idioms

  • RAND USR 16514 — the standard ZX81 idiom for calling a machine code address. RANDOMIZE USR discards the return value without error.
  • POKE 16515, n — directly modifies the second byte of the REM statement (the operand of LD A, n), achieving self-modification from BASIC.
  • GOTO 2 at line 6 creates an infinite animation loop over lines 2–5.

Unreachable Lines

Lines 8 and 9 (PRINT AT 10,8;"MERRY CHRISTMAS" and GOTO 2) are never reached during normal execution because line 6 unconditionally jumps back to line 2. These lines may be a remnant of an earlier version where the loop included a print step, or they may have been intended as a fallback that was later superseded by the machine code display routine.

Notable Observations

  • The machine code references address 400Ch, which on the ZX81 falls within the display file area — confirming the routine writes directly to video RAM.
  • The two alternating values, 6 and 134 (= 6 + 128), are a normal character and its inverse-video equivalent, producing a blinking border effect.
  • The tight DJNZ loops make the routine fast enough to produce visible flicker animation without any additional PAUSE or delay.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Merry Christmas Message

Source Code

   1 REM E



Merry Christmas Message

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Holiday

This program displays a “MERRY CHRISTMAS” greeting using a machine code routine embedded in a REM statement at line 1. The machine code, stored from address 16514 onward, is a Z80 routine that manipulates the display — it uses register pairs and relative jumps (DJNZ loops) to write directly to screen memory. Lines 3 and 5 use POKE 16515 to modify a byte within the REM/machine code area itself, effectively self-modifying the routine’s behaviour between two calls via RAND USR 16514. The PRINT AT statement at line 8 positions the greeting text at row 10, column 8, and the GOTO 2 loop continuously cycles the display effect.


Program Analysis

Program Structure

The program is short but layered. Line 1 holds a REM statement whose body is raw Z80 machine code. Lines 2–6 form the main execution loop: call the machine code routine, poke a new value into it, call it again with the modified byte, then repeat forever via GOTO 2. Line 7 is a SAVE command that would save the program. Line 8 prints the greeting, and line 9 loops back — though line 8 and 9 are never reached by the main loop at line 6, suggesting the program was perhaps edited or the loop is intended to cycle only through lines 2–6.

Machine Code in the REM Statement

On the ZX81/TS1000, a REM statement’s text bytes begin at address 16514 (the byte immediately after the line-length and REM token). The bytes stored there are:

OffsetHexZ80 MnemonicNotes
03E 86LD A, 86hLoad accumulator with 134
22A 0C 40LD HL, (400Ch)Load HL from display address area
506 20LD B, 32Counter for 32 bytes
723INC HLAdvance pointer
877LD (HL), AWrite A to screen memory
910 FCDJNZ -4Loop 32 times
1106 14LD B, 20Counter for 20 rows
1323 23INC HL / INC HLSkip two bytes
1577LD (HL), AWrite pattern
1611 1F 00LD DE, 31Row stride
1919ADD HL, DEAdvance by one row
2077LD (HL), AWrite pattern
2110 F6DJNZ -10Loop 20 rows
2323INC HL
2406 20LD B, 32Counter for 32 bytes
2623INC HL
2777LD (HL), AWrite pattern
2810 FCDJNZ -4Loop 32 times
30C9RETReturn to BASIC

The routine draws a rectangular border pattern around the screen by writing the value in the accumulator to a run of display file bytes. The first call (line 2) uses whatever byte is currently at offset 1 of the REM (initially 86h = 134, a ZX81 graphics character). Line 3 then POKEs address 16515 (offset 1, the immediate operand of LD A, n) to 6, changing the character written. Line 4 calls the routine again with this new value, creating an animation toggle effect.

Self-Modification Technique

The key idiom here is patching the machine code’s own immediate operand through POKE 16515. Because the LD A, n instruction’s operand sits at a known, fixed address within the REM statement, lines 3 and 5 alternate the value between 6 and 134 (decimal), causing the border pattern to flash between two different graphic characters on each loop iteration. This is a classic ZX81 self-modifying code pattern used to squeeze animation out of minimal ROM calls.

Key BASIC Idioms

  • RAND USR 16514 — the standard ZX81 idiom for calling a machine code address. RANDOMIZE USR discards the return value without error.
  • POKE 16515, n — directly modifies the second byte of the REM statement (the operand of LD A, n), achieving self-modification from BASIC.
  • GOTO 2 at line 6 creates an infinite animation loop over lines 2–5.

Unreachable Lines

Lines 8 and 9 (PRINT AT 10,8;"MERRY CHRISTMAS" and GOTO 2) are never reached during normal execution because line 6 unconditionally jumps back to line 2. These lines may be a remnant of an earlier version where the loop included a print step, or they may have been intended as a fallback that was later superseded by the machine code display routine.

Notable Observations

  • The machine code references address 400Ch, which on the ZX81 falls within the display file area — confirming the routine writes directly to video RAM.
  • The two alternating values, 6 and 134 (= 6 + 128), are a normal character and its inverse-video equivalent, producing a blinking border effect.
  • The tight DJNZ loops make the routine fast enough to produce visible flicker animation without any additional PAUSE or delay.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Merry Christmas Message

Source Code

   1 REM \3E\86\2A\0C\40\06\20\23\77\10\FC\06\14\23\23\77\11\1F\00\19\77\10\F6\23\06\20\23\77\10\FC\C9
   2 RAND USR 16514
   3 POKE 16515,6
   4 RAND USR 16514
   5 POKE 16515,134
   6 GOTO 2
   7 SAVE "1008%9"
   8 PRINT AT 10,8;"MERRY  CHRISTMAS"
   9 GOTO 2

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

Merry Christmas Message

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Holiday

This program displays a “MERRY CHRISTMAS” greeting using a machine code routine embedded in a REM statement at line 1. The machine code, stored from address 16514 onward, is a Z80 routine that manipulates the display — it uses register pairs and relative jumps (DJNZ loops) to write directly to screen memory. Lines 3 and 5 use POKE 16515 to modify a byte within the REM/machine code area itself, effectively self-modifying the routine’s behaviour between two calls via RAND USR 16514. The PRINT AT statement at line 8 positions the greeting text at row 10, column 8, and the GOTO 2 loop continuously cycles the display effect.


Program Analysis

Program Structure

The program is short but layered. Line 1 holds a REM statement whose body is raw Z80 machine code. Lines 2–6 form the main execution loop: call the machine code routine, poke a new value into it, call it again with the modified byte, then repeat forever via GOTO 2. Line 7 is a SAVE command that would save the program. Line 8 prints the greeting, and line 9 loops back — though line 8 and 9 are never reached by the main loop at line 6, suggesting the program was perhaps edited or the loop is intended to cycle only through lines 2–6.

Machine Code in the REM Statement

On the ZX81/TS1000, a REM statement’s text bytes begin at address 16514 (the byte immediately after the line-length and REM token). The bytes stored there are:

OffsetHexZ80 MnemonicNotes
03E 86LD A, 86hLoad accumulator with 134
22A 0C 40LD HL, (400Ch)Load HL from display address area
506 20LD B, 32Counter for 32 bytes
723INC HLAdvance pointer
877LD (HL), AWrite A to screen memory
910 FCDJNZ -4Loop 32 times
1106 14LD B, 20Counter for 20 rows
1323 23INC HL / INC HLSkip two bytes
1577LD (HL), AWrite pattern
1611 1F 00LD DE, 31Row stride
1919ADD HL, DEAdvance by one row
2077LD (HL), AWrite pattern
2110 F6DJNZ -10Loop 20 rows
2323INC HL
2406 20LD B, 32Counter for 32 bytes
2623INC HL
2777LD (HL), AWrite pattern
2810 FCDJNZ -4Loop 32 times
30C9RETReturn to BASIC

The routine draws a rectangular border pattern around the screen by writing the value in the accumulator to a run of display file bytes. The first call (line 2) uses whatever byte is currently at offset 1 of the REM (initially 86h = 134, a ZX81 graphics character). Line 3 then POKEs address 16515 (offset 1, the immediate operand of LD A, n) to 6, changing the character written. Line 4 calls the routine again with this new value, creating an animation toggle effect.

Self-Modification Technique

The key idiom here is patching the machine code’s own immediate operand through POKE 16515. Because the LD A, n instruction’s operand sits at a known, fixed address within the REM statement, lines 3 and 5 alternate the value between 6 and 134 (decimal), causing the border pattern to flash between two different graphic characters on each loop iteration. This is a classic ZX81 self-modifying code pattern used to squeeze animation out of minimal ROM calls.

Key BASIC Idioms

  • RAND USR 16514 — the standard ZX81 idiom for calling a machine code address. RANDOMIZE USR discards the return value without error.
  • POKE 16515, n — directly modifies the second byte of the REM statement (the operand of LD A, n), achieving self-modification from BASIC.
  • GOTO 2 at line 6 creates an infinite animation loop over lines 2–5.

Unreachable Lines

Lines 8 and 9 (PRINT AT 10,8;"MERRY CHRISTMAS" and GOTO 2) are never reached during normal execution because line 6 unconditionally jumps back to line 2. These lines may be a remnant of an earlier version where the loop included a print step, or they may have been intended as a fallback that was later superseded by the machine code display routine.

Notable Observations

  • The machine code references address 400Ch, which on the ZX81 falls within the display file area — confirming the routine writes directly to video RAM.
  • The two alternating values, 6 and 134 (= 6 + 128), are a normal character and its inverse-video equivalent, producing a blinking border effect.
  • The tight DJNZ loops make the routine fast enough to produce visible flicker animation without any additional PAUSE or delay.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Merry Christmas Message

Source Code

   1 REM \3E\86\2A\0C\40\06\20\23\77\10\FC\06\14\23\23\77\11\1F\00\19\77\10\F6\23\06\20\23\77\10\FC\C9
   2 RAND USR 16514
   3 POKE 16515,6
   4 RAND USR 16514
   5 POKE 16515,134
   6 GOTO 2
   7 SAVE "1008%9"
   8 PRINT AT 10,8;"MERRY  CHRISTMAS"
   9 GOTO 2

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\FC itemtype='https://schema.org/Blog' itemscope='itemscope' class="wp-singular computer_media-template-default single single-computer_media postid-57140 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.5 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"F

Merry Christmas Message

This file is part of Timex Sinclair Public Domain Library Tape 1002 . Download the collection to get this file.
Date: 198x
Type: Program
Platform(s): TS 1000
Tags: Holiday

This program displays a “MERRY CHRISTMAS” greeting using a machine code routine embedded in a REM statement at line 1. The machine code, stored from address 16514 onward, is a Z80 routine that manipulates the display — it uses register pairs and relative jumps (DJNZ loops) to write directly to screen memory. Lines 3 and 5 use POKE 16515 to modify a byte within the REM/machine code area itself, effectively self-modifying the routine’s behaviour between two calls via RAND USR 16514. The PRINT AT statement at line 8 positions the greeting text at row 10, column 8, and the GOTO 2 loop continuously cycles the display effect.


Program Analysis

Program Structure

The program is short but layered. Line 1 holds a REM statement whose body is raw Z80 machine code. Lines 2–6 form the main execution loop: call the machine code routine, poke a new value into it, call it again with the modified byte, then repeat forever via GOTO 2. Line 7 is a SAVE command that would save the program. Line 8 prints the greeting, and line 9 loops back — though line 8 and 9 are never reached by the main loop at line 6, suggesting the program was perhaps edited or the loop is intended to cycle only through lines 2–6.

Machine Code in the REM Statement

On the ZX81/TS1000, a REM statement’s text bytes begin at address 16514 (the byte immediately after the line-length and REM token). The bytes stored there are:

OffsetHexZ80 MnemonicNotes
03E 86LD A, 86hLoad accumulator with 134
22A 0C 40LD HL, (400Ch)Load HL from display address area
506 20LD B, 32Counter for 32 bytes
723INC HLAdvance pointer
877LD (HL), AWrite A to screen memory
910 FCDJNZ -4Loop 32 times
1106 14LD B, 20Counter for 20 rows
1323 23INC HL / INC HLSkip two bytes
1577LD (HL), AWrite pattern
1611 1F 00LD DE, 31Row stride
1919ADD HL, DEAdvance by one row
2077LD (HL), AWrite pattern
2110 F6DJNZ -10Loop 20 rows
2323INC HL
2406 20LD B, 32Counter for 32 bytes
2623INC HL
2777LD (HL), AWrite pattern
2810 FCDJNZ -4Loop 32 times
30C9RETReturn to BASIC

The routine draws a rectangular border pattern around the screen by writing the value in the accumulator to a run of display file bytes. The first call (line 2) uses whatever byte is currently at offset 1 of the REM (initially 86h = 134, a ZX81 graphics character). Line 3 then POKEs address 16515 (offset 1, the immediate operand of LD A, n) to 6, changing the character written. Line 4 calls the routine again with this new value, creating an animation toggle effect.

Self-Modification Technique

The key idiom here is patching the machine code’s own immediate operand through POKE 16515. Because the LD A, n instruction’s operand sits at a known, fixed address within the REM statement, lines 3 and 5 alternate the value between 6 and 134 (decimal), causing the border pattern to flash between two different graphic characters on each loop iteration. This is a classic ZX81 self-modifying code pattern used to squeeze animation out of minimal ROM calls.

Key BASIC Idioms

  • RAND USR 16514 — the standard ZX81 idiom for calling a machine code address. RANDOMIZE USR discards the return value without error.
  • POKE 16515, n — directly modifies the second byte of the REM statement (the operand of LD A, n), achieving self-modification from BASIC.
  • GOTO 2 at line 6 creates an infinite animation loop over lines 2–5.

Unreachable Lines

Lines 8 and 9 (PRINT AT 10,8;"MERRY CHRISTMAS" and GOTO 2) are never reached during normal execution because line 6 unconditionally jumps back to line 2. These lines may be a remnant of an earlier version where the loop included a print step, or they may have been intended as a fallback that was later superseded by the machine code display routine.

Notable Observations

  • The machine code references address 400Ch, which on the ZX81 falls within the display file area — confirming the routine writes directly to video RAM.
  • The two alternating values, 6 and 134 (= 6 + 128), are a normal character and its inverse-video equivalent, producing a blinking border effect.
  • The tight DJNZ loops make the routine fast enough to produce visible flicker animation without any additional PAUSE or delay.

Content

Appears On

Assembled by Tim Ward from many sources. Contains programs 10051 – 10121.

Related Products

Related Articles

Related Content

Image Gallery

Merry Christmas Message

Source Code

   1 REM \3E\86\2A\0C\40\06\20\23\77\10\FC\06\14\23\23\77\11\1F\00\19\77\10\F6\23\06\20\23\77\10\FC\C9
   2 RAND USR 16514
   3 POKE 16515,6
   4 RAND USR 16514
   5 POKE 16515,134
   6 GOTO 2
   7 SAVE "1008%9"
   8 PRINT AT 10,8;"MERRY  CHRISTMAS"
   9 GOTO 2

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

People

No people associated with this content.

Scroll to Top
\F6\FC\C9 2 RAND USR 16514 3 POKE 16515,6 4 RAND USR 16514 5 POKE 16515,134 6 GOTO 2 7 SAVE "1008%9" 8 PRINT AT 10,8;"MERRY CHRISTMAS" 9 GOTO 2

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

People

No people associated with this content.

Scroll to Top