mappum/DCPU-16 — pull request #19 by Twisol (2012-04-06 06:48:08+00:00)
Title: Memory-mapped devices

Hallo again!

This set of commits covers mapping external devices into CPU-accessible memory. The most obvious change here is the removal of the GET opcode. In order to accept input, all that's needed is a device mapped into memory with a `get` callback.

With the removal of GET, I've modified the demo to mount a non-standard input device at 0x7FFF (that is, one word before the output device).

cpu.mapDevice(0x7FFF, 1, input);

To use this device, just use `SET A, [0x7FFF]` to read a character into the A register. To place it straight into the output region, you can use `SET [0x8000], [0x7FFF]`.

If I may be so bold, I suspect this will be exactly how networking and other peripherals will be done in 0x10c itself. (I mean, Notch is already using a memory-mapped device for his screen...)