Some little time ago I posted
Puzzle challenge: An unusual idea, but not a new onewith an idea and some half-baked code. It's time to get it out in the open ...spoilers ahead for anyone who wanted to tackle the puzzle...
...
...
...
The idea is that even on a device with no I/O devices, you can save data by putting out radio interference.
(Beware of local regulations and don't abuse this new power! Especially if you have a radio license to lose - perform all experiments within a Faraday cage.)
So, every micro has data lines and address lines bouncing up and down at megahertz rates - can we do anything to control that? It turns out we can! With a 2MHz 6502, as found in the BBC micro, a counted loop which crosses a major address boundary can toggle many of the address lines at 200kHz, which is nicely in the middle of the long wave band, and more or less on top of Radio 4 at 198kHz.
Here's my inner loop:
Code:
.loop5 SBC #1:JMP skip5
.skip5 NOP:BNE loop5:RTS
or, more conventionally:
Code:
loop5:
SBC #1
JMP skip5
skip5:
NOP
BNE loop5
RTS
which is a ten-cycle loop. At 2MHz, that's 200kHz.
There'll be lots of other frequency components, but should be a strong contribution at 200kHz.
If we had a strong constant sine wave output at that frequency, a nearby radio tuning around the middle of the long wave should have a bit of a drop in the static it picks up as it passes that carrier. That's what I thought anyway.
As it turns out (and as I recall) I got a horrible buzz across quite a bit of the band, from a radio put right on top of the machine. Bear in mind that the UK computers of the 80s didn't really have shielding - one of several reasons why they struggled to export to the US.
My thinking was, if there's any modulation of the strength of our signal, at audio rates, we should get some kind of sound from the radio. Especially if we'd managed to get silence from our "carrier."
So, with my loop5 routine producing strong carrier, I wrote a loop15 like this:
Code:
.loop15 SEC:BCS skip15a
.skip15a SBC #1:JMP skip15b
.skip15b NOP:JMP skip15c
.skip15c NOP:JMP skip15d
.skip15d NOP:JMP skip15e
.skip15e NOP:BNE loop15
The idea here is to waste a lot more time and cross the major address boundary less often.
Code:
loop15:
SEC
BCS skip15a
skip15a:
SBC #1
JMP skip15b
skip15b:
NOP
JMP skip15c
skip15c:
NOP
JMP skip15d
skip15d:
NOP
JMP skip15e
skip15e:
NOP
BNE loop15
That's a 30-cycle loop. My thinking was, if my output is a square wave (of course it isn't) then the fundamental is now at 200/3 and the weaker first harmonic is at 200.
So, if I alternate between these routines, I can modulate my "carrier" at an audio rate. And that's what I was trying to do with my innerlo and innerhi routines:
Code:
LDX #48
.innerhi
LDA #42:JSR loop5
LDA #14:JSR loop15
DEX:BNE innerhi
Code:
LDX #24
.innerlo
LDA #42:JSR loop5
LDA #42:JSR loop5
LDA #14:JSR loop15
LDA #14:JSR loop15
DEX:BNE innerlo
(Thanks to Jeff for the bugfixes to those!)
My ideal result would be that I can get the radio to output one of two tones, and then it's a simple matter of programming to output data from the 6502 machine, over the radio, in a format which might even be compatible with cassette tape storage.
The actual result was some kind of horrible warbling - by no means alternating between two nice tones, but certainly an audio-modulated signal!
At that point I put the project down, and walked away...