Gaming In Different Languages

One of the perks of using older hardware is its comparative simplicity and extensive documentation. After years or decades of users programming on a platform, the amount of knowledge available for it can become extensive. This is certainly the case with the 6502 microprocessor, used in old Apple computers and some video game systems from the ’80s. The extensive amount of resources available make it a prime candidate in exploring various programming languages, and their advantages and disadvantage.

This project looks into those differences using a robot game, which has been programmed four different ways in three languages. [Joey] created the game in Python first and then began to port it to the 65C02, a CMOS variant of the 6502. The first iteration is its assembly language, and then a second iteration with optimized assembly code. From there, he ports it to C and then finally to Forth. Each version of the game is available to play in a browser using an emulator to run the 6502 hardware.

Since the games run in the browser, other tools are available to examine the way the game runs in each language. Registers can be viewed in real time, as well as the values stored in the memory. It’s an interesting look at an old piece of hardware and of its inner workings. For an even deeper dive into the 6502, it’s possible to build a working computer on breadboards using one.

Where The Work Is Really Done – Casual Profiling

Once a program has been debugged and works properly, it might be time to start optimizing it. A common way of doing this is a method called profiling – watching a program execute and counting the amount of computing time each step in the program takes. This is all well and good for most programs, but gets complicated when processes execute on more than one core. A profiler may count time spent waiting in a program for a process in another core to finish, giving meaningless results. To solve this problem, a method called casual profiling was developed.

In casual profiling, markers are placed in the code and the profiler can measure how fast the program gets to these markers. Since multiple cores are involved, and the profiler can’t speed up the rest of the program, it actually slows everything else down and measures the markers in order to simulate an increase in speed. [Daniel Morsig] took this idea and implemented it in Go, with an example used to demonstrate its effectiveness speeding up a single process by 95%, resulting in a 22% increase in the entire program. Using a regular profiler only counted a 3% increase, which was not as informative as the casual profiler’s 22% measurement.

We got this tip from [Greg Kennedy] who notes that he hasn’t seen much use of casual profiling outside of the academic world, but we agree that there is likely some usefulness to this method of keeping track of a multi-threaded program’s efficiency. If you know of any other ways of solving this problem, or have seen causal profiling in use in the wild, let us know in the comments below.

Header image: Alan Lorenzo [CC BY-SA 3.0].

Hacking The Pocket Operator

The number of easily usable and programmable microcontrollers is small, so when selecting one for a project there are only a handful of very popular, well documented chips that most of us reach for. The same can be said for most small companies selling electronics as well, so if you reach for a consumer device that is powered by a microcontroller it’s likely to have one of these few in it. As a result, a lot of these off-the-shelf devices are easy to hack, reprogram, or otherwise improve, such as the Robot Pocket Operator.

The Pocket Operator is a handheld, fully-featured synthesizer complete with internal speaker. It runs on a Cortex M3, a very popular ARM processor which has been widely used for many different applications, and features everything you would need for a synthesizer in one tiny package, including a built-in speaker. It also supports a robust 24-bit DAC/ADC and all the knobs and buttons you would need. And now, thanks to [Frank Buss] there is a detailed teardown on exactly how this device operates.

Some of the highlights from the teardown include detailed drawings of how the display operates, all of the commands for controlling the device, and even an interesting note about how the system clock operates even when the device has been powered off for a substantial amount of time. For a pocket synthesizer this has a lot to offer, even if you plan on using it as something else entirely thanks to the versatility of the Cortex M3.

Continue reading “Hacking The Pocket Operator”

An Arduino From The Distant Past

Arduinos are a handy tool to have around. They’re versatile, cheap, easy to program, and have a ton of software libraries to build on. They’ve only been around for about a decade and a half though, so if you were living in 1989 and wanted to program a microcontroller you’d probably be stuck with an 8-bit microprocessor with no built-in peripherals to help, reading from a physical book about registers and timing, and probably trying to get a broken ribbon cable to behave so it would actually power up. If you want a less frustrating alternate history to live in, though, check out the latest project from [Marek].

He discovered some 6502 chips (Polish language, Google Translate link) that a Chinese manufacturer was selling, but didn’t really trust that they were legitimate. On a lark he ordered some and upon testing them he found out that they were real 6502s. Building an 8-bit computer is something he’d like to do, but in the meantime he decided to do a project using one of these chips as a general-purpose microcontroller similar to a modern Arduino. The project has similar specs as an Arduino too, including 8kB of RAM memory, 8kB of I/O address space, and various EPROM capabilities. [Marek] went on to build a shield board for it as well, for easy access to some switches and LEDs. It’s a great build that anyone interested in microcontrollers should check out.

Keep in mind that an ATtiny45 has 8 bits like the 6502 but only costs around $1 USD, whereas a 6502 would have cost around $200 in today’s dollars. It’s really only in modern times that we can appreciate the 6502 as a cheap 8-bit microcontroller for that reason alone, but we can also appreciate how it ushered in a computer revolution since competing Intel and Motorola chips cost around six times more before it showed up. They became so popular in fact that people still regularly use them to build retrocomputers of all kinds.

Bespoke Processors Might Soon Power Your Artisanal Devices

Modern microprocessors are a marvel of technological progress and engineering. At less than a dollar per unit, even the cheapest microprocessors on the market are orders of magnitude more powerful than their ancestors. The first commercially available single-chip processor, the Intel 4004, cost roughly $25 (in today’s dollars) when it was introduced in 1971.

The 4-bit 4004 clocked in at 740 kHz — paltry by today’s standards, but quite impressive at the time. However, what was remarkable about the 4004 was the way it shifted computer design architecture practically overnight. Previously, multiple chips were used for processing and were selected to just meet the needs of the application. Considering the cost of components at the time, it would have been impractical to use more than was needed.

That all changed with the new era ushered in by general purpose processors like the 4004. Suddenly it was more cost-effective to just grab a processor of the shelf than to design and manufacture a custom one – even if that processor was overpowered for the task. That trend has continued (and has been amplified) to this day. Your microwave probably only uses a fraction of its processing power, because using a $0.50 processor is cheaper than designing (and manufacturing) one tailored to the microwave’s actual needs.

Anyone who has ever worked in manufacturing, or who has dealt with manufacturers, knows this comes down to unit cost. Because companies like Texas Instruments makes millions of processors, they’re very inexpensive per unit. Mass production is the primary driving force in affordability. But, what if it didn’t have to be?

Professors [Rakesh Kumar] and [John Sartori], along with their students, are experimenting with bespoke processor designs that aim to cut out the unused portions of modern processors. They’ve found that in many applications, less than half the logic gates of the processor are actually being used. Removing these reduces the size and power consumption of the processor, and therefore the final size and power requirements of the device itself.

Of course, that question of cost comes back into play. Is a smaller and more efficient processor worth it if it ends up costing more? For most manufacturers of devices today, the answer is almost certainly no. There aren’t many times when those factors are more important than cost. But, with modern techniques for printing electronics, they think it might be feasible in the near future. Soon, we might be looking at custom processors that resemble the early days of computer design.


Under The Hood Of AMD’s Threadripper

Although AMD has been losing market share to Intel over the past decade, they’ve recently started to pick up steam again in the great battle for desktop processor superiority. A large part of this surge comes in the high-end, multi-core processor arena, where it seems like AMD’s threadripper is clearly superior to Intel’s competition. Thanks to overclocking expert [der8auer] we can finally see what’s going on inside of this huge chunk of silicon.

The elephant in the room is the number of dies on this chip. It has a massive footprint to accommodate all four dies, each with eight cores. However, it seems as though two of the cores are deactivated due to a combination of manufacturing processes and thermal issues. This isn’t necessarily a bad thing, either, or a reason not to use this processor if you need to utilize a huge number of cores, though; it seems as though AMD found it could use existing manufacturing techniques to save on the cost of production, while still making a competitive product.

Additionally, a larger die size than required opens the door for potentially activating the two currently disabled chips in the future. This could be the thing that brings AMD back into competition with Intel, although both companies still maintain the horrible practice of crippling their chips’ security from the start.

The Gray-1, A Computer Composed Entirely Of ROM And RAM

When we learn about the internals of a microprocessor, we are shown a diagram that resembles the 8-bit devices of the 1970s. There will be an ALU, a program counter, a set of registers, and address and data line decoders. Most of us never go significantly further into the nuances of more modern processors because there is no need. All a processor needs to be is a black box, unless it has particularly sparked your interest or you are working in bare-metal assembly language.

We imagine our simple microprocessor as built from logic gates, and indeed there have been many projects on these pages that create working processors from piles of 74 series chips. But just occasionally a project comes along that reminds us there is more than one way to build a computer, and our subject today is just such a moment. [Olivier Bailleux] has created his “Gray-1”, a processor whose only active components are memory chips, both ROM and RAM.

The clever part comes with the descriptions of how the ROMs are used to recreate the different functions of the processor, through careful programming. Some functions such as registers for example use loops, in which some of the address lines are driven from the data lines to maintain the ROM at a set location. The name of the computer comes from its program counter, which counts in Gray code.

The full processor implements a RISC architecture, and there is a simulator to allow code development without a physical unit. The write-up is both comprehensive and accessible, and makes a fascinating read.

It’s safe to say this is the only processor we’ve seen with this novel approach to architecture. Some more conventional previous features though have been an effort to create a processor entirely from NAND gates, and another made from 74 logic.