Skip to content

Perplexity 7: Ghost in the Machine (code) Mystery Cache

Hidden : 3/6/2014
Difficulty:
5 out of 5
Terrain:
1.5 out of 5

Size: Size:   small (small)

Join now to view geocache location details. It's free!

Watch

How Geocaching Works

Please note Use of geocaching.com services is subject to the terms and conditions in our disclaimer.

Geocache Description:

This is a puzzle cache. The container is not hidden at the coordinates given. You can find the correct coordinates by using the information on this page to solve the puzzle!

This cache is part of a series around the area where I live. I like solving puzzles so I thought that I would make that the theme for my first set of caches. I hope that you enjoy them and that they are sufficiently challenging without being too frustrating.



The only language that the processor of a computer understands is called machine code. Each machine code instruction corresponds to a pattern of high and low voltages applied to the physical pins of the processor chip, that control what it does next.

But programmes aren't written in machine code. They are written in high level languages that have instructions for doing things like storing information on disk, creating arrays of floating point numbers and displaying information on the screen. Programmes written in high level language are much easier to debug, maintain and adapt to run on different hardware.

Programmes written in high level language are munched and crunched by a big complex programme called a compiler that translates them into an intermediate form approaching machine code. Another programme called a linker then grafts on generous slabs of pre-written code (called libraries) to implement local functions like communicating with the computer's hardware. Finally the resulting executable is handed over to the computer's Operating System which as and when it sees fit allows it to run bit by bit, alongside all the other things it is doing.

So nobody in their right mind would want to write directly in machine code. Or... would they...? Machine code is terse, cryptic and lacks complex instructions - but it is FAST. Eye-wateringly fast. It is also POWERFUL as it gives you direct unfettered control of the processor without any hand-holding overhead or someone else's idea of how your code should run. Writing machine code is a bit like constructing a Japanese haiku - you have to be infinitely attentive to detail and it's very easy to get things wrong.

When I first started programming back in the late '70s and early 80's, programming in machine code was really the only way to get a computer to go fast enough to do anything really cool (i.e. space invaders - my personal vision of nirvana). So a lot of us got pretty familiar with it.

Back in those days there were two different types of processors in home computers. If you had a Sinclair ZX80, ZX81 or Spectrum it contained a Zilog Z80; or if you had a Commodore Pet, Apple I, Acorn Atom or BBC micro it contained a MOS Technologies 6502. I had an Acorn Atom and later a BBC Micro, so I was a 6502 lad.

Processors then were far simpler than their modern equivalents but even in comparison to the Z80 (which had built-in loop instructions) the 6502 was extremely stripped-down: just three eight-bit registers, and a restrictive set of addressing modes that could most charitably be described as 'idiosyncratic'.

Despite its restrictions and quirks many people loved the 6502 and programming it was certainly an artform. It even still has some fans today who are still using it as the basis for homebrew systems (e.g. see http://www.6502.org).

As an exercise I recently dusted off an old manual or two and wrote the example of 6502 code below. To make it a bit more of a challenge I set myself the objective of (a) the code being fully relocatable - i.e. can be loaded and run at any memory address; and (b) not using any page zero locations. Makes me feel quite nostalgic...

A9 60 A2 FE 78 9A 8D FC 01 20 FC 01 CA CA 9A 8D FF 01 A9 9D 48 58 AD FD 01 A2 2B 20 FC 01 AD FE 01 E8 20 FC 01 A2 30 20 FC 01 AD FD 01 CA 20 FC 01 A0 25 A2 38 BD FF FF E8 5D FF FF 20 FC 01 88 D0 F6 00 2A 7E 3C 0D 45 43 02 02 0B 0D 45 49 1A 53 41 15 54 6E 7B 04 11 14 00 1A 1B 04 02 13 77 67 00 10 12 00 1C 1F 02 01

If you're curious and want to have a go at working out what this code does then you might find the following website useful: http://e-tradition.net/bytes/6502/6502_instruction_set.html

important notes: (1) remember to set the program counter (PC) to the beginning of the code before you commence execution; (2) only run the code once unless you reload it fresh, otherwise you will confuse the ghost!

You can check your answers for this puzzle on GeoChecker.com.


When originally placed the cache contained a logbook, pencil, small prize for the FTF and an original Acorn Operating System ROM (which should remain in the cache please).

Further background on the merits of writing in machine code can be found here.

Additional Hints (Decrypt)

[hint for GZ]phy qr fnp jbbqra qbbe

Decryption Key

A|B|C|D|E|F|G|H|I|J|K|L|M
-------------------------
N|O|P|Q|R|S|T|U|V|W|X|Y|Z

(letter above equals below, and vice versa)