Applesoft BASIC, 21 bytes (tokenized)
0 PRINT 9 + 1: CALL 2066: END : OR <CTRL-F><CTRL-H>`
Replace <CTRL-F>
and <CTRL-H>
with their literal versions. Note that this only modifies the program in memory; re-loading it from the disk will reset the countdown.
Explanation
Sample run
]RUN
10
]RUN
9
]RUN
8
]RUN
7
]RUN
6
]RUN
5
]RUN
4
]RUN
3
]RUN
2
]RUN
1
]RUN
?SYNTAX ERROR IN 0
Explanation
PRINT 9 + 1
does what you'd expect. CALL 2066
calls the 6502 machine-language routine at memory location 2066, which is after END :
. END
halts the program so that the machine-language routine (which, to the Applesoft interpreter, is garbage) isn't executed.
The machine-language routine simply decrements the 9
in PRINT 9 + 1
. Disassembly:
0812- CE 06 08 DEC $0806
0815- 60 RTS
After the counter reaches 0, it is "decremented" to /
; attempting to run the program will then cause a syntax error.