The X Macro: A Historic Preprocessor Hack

If we told you that a C preprocessor hack dated back to 1968, you’d be within your rights to remind us that C didn’t exist in 1968. However, assemblers with preprocessors did, and where there is a preprocessor, there is an opportunity to do clever things. One of those things is the so-called X macro, which saw a lot of use in DEC System 10 code but probably dates back even earlier. You can still use it today if you like, even though there are, of course, other arguably better ways to get the same result. However, the X macro can be very efficient, and you may well run into it in some code, too.

Background

Preprocessing used to be a staple of programming. The idea is that code is manipulated purely at the text level before it is compiled. These days, languages with a preprocessor usually handle it as part of the compiler, but you can also use an external preprocessor like m4 for more sophisticated uses.

Modern languages tend to provide other ways to accomplish many of the tasks handled by the preprocessor. For example, if you have a constant you want to set at compile time, you could say:

int X = 32;
y = X;

But then you’ve created a real variable along with the overhead that might entail. A smart compiler might optimize it away for you, but you can be sure by writing:

#define X 32
y = X;

A modern compiler would prefer you to write:

const int X=32;
y = X;

But there are still some common uses for macros, like including header files. You can also make more sophisticated macros with arguments so you don’t incur a function call penalty, although modern usage would be to mark those functions as inline.

The Problem

Which brings us to the X macro. With all great hacks, there is first a problem to solve. Imagine you have a bunch of electronic parts you want to deal with in your code. You don’t want a database, and you don’t want to carry a bunch of strings around, so you define an enumerated type:

Continue reading “The X Macro: A Historic Preprocessor Hack”

Raspberry Pi Adds Second Laptop Monitor

If you have a cheap laptop and you realize you can’t connect a second monitor to it, what do you do? Well, if you are [Pierre Couy], you grab a Raspberry Pi and put together a virtual screen solution.

Like all good projects, this one started with some goals and requirements:

  • Low latency
  • Redable text
  • At least 10 frames per second
  • Fast catch up if the remote screen falls behind
  • Low-bitrate encoding; no hardware acceleration
  • A DHCP server on the Pi to manage the network
  • Power control for the attached monitor

Continue reading “Raspberry Pi Adds Second Laptop Monitor”

Retrotechtacular: Military Graphics In The 1960s

While you might think the military doesn’t have a sense of humor with names. Take the AN/MSQ-19 “automated tactical operations central” for example. (Video, embedded below.) But then, when you find out that the truck-sized computer at the heart of it was MOBIDIC — yes, that’s pronounced Moby Dick — you know someone had a good chuckle somewhere. The video below was a promotional video from the early 1960s, and although it shows the unit in operation, it was most likely a mockup and not fully functional.

The MOBIDIC program ran from 1960-1964 and cost a whopping $25 million in 1960-era money. In 1964, testing revealed the system was too unwieldy, requiring at least five tractor-trailers, eight generators, portable buildings, and several large trucks to move around.

Continue reading “Retrotechtacular: Military Graphics In The 1960s”

Three Way LED Bulb Gives Up Its Secrets

You’ve probably seen three-way bulbs. You know, the ones that can go dim or bright with each turn of a switch. [Brian Dipert] wondered how the LED version of these works, and now that he tore one apart, you can find out, too. The old light bulbs were easy to figure out. They had two filaments, one brighter than the other. Switching on the first filament provided some light, and the second gave off more light. The final position lit both filaments at once for an even brighter light.

LED or filament, three-way bulbs have a special base. While a normal Edison-base bulb has the threaded part as the neutral and a center contact for the live wire, a three-way bulb has an extra hot contact ring between the threaded part and the center contact. Obviously, a compatible LED bulb will need this same interface, but will work differently inside.

Inside the LED, [Brian] found two rings of LEDs that took the place of the filaments. He was able to identify all the ICs and devices on the board except one, an MT7712S. If you can read Mandarin, we think this is the datasheet for it.

We weren’t sure what [Brian] would find inside. After all, you could just sense which contacts had voltage and dim the LEDs using PWM. It probably wouldn’t take any less circuitry. LED lighting is everywhere these days, and maybe they don’t all work the same, but you have to admit, using two strings of LEDs is reasonably faithful to the old-fashioned bulbs.

Sometimes LED bulbs are different depending on where you buy them. We were promised LED bulbs would never burn out. Of course, they do, but you can usually scrounge some LEDs from them.

The Nixie Clock From Outer Space

Nixie clocks are nothing new. But [CuriousMarc] has one with a unique pedigree: the Apollo Program. While restoring the Apollo’s Central Timing Equipment box, [Marc] decided to throw together a nixie-based clock. The avionics unit in question sent timing pulses and a mission elapsed time signal to the rest of the spacecraft. Oddly enough, while it had an internal oscillator, it was only used during failures. It normally synched to the guidance computer’s onboard clock.

There is a detailed explanation of the unit, along with some of the ancillary equipment and panels. Much of what the output from the unit is driving counters to display timers, although some of the clocks drive other pieces of equipment, like the telemetry commutator, which time stamps each telemetry frame.

Continue reading “The Nixie Clock From Outer Space”

Enzymes Make Electricity From Thin Air

There’s an old magic trick known as the miser’s dream, where the magician appears to pull coins from thin air. Australian scientists say they can now generate electricity out of thin air with the help of some enzymes. The enzyme reacts to hydrogen in the atmosphere to generate a current.

They learned the trick from bacteria which are known to use hydrogen for fuel in inhospitable environments like Antarctica or in volcanic craters. Scientists knew hydrogen was involved but didn’t know how it worked until now.

The enzyme is very efficient and can even work on trace amounts of hydrogen. The enzyme can survive freezing and temperature up to 80 °C (176 °F). The paper seems more intent on the physical mechanisms involved, but you can tell the current generated is minuscule. We don’t expect to see air-powered cell phones anytime soon. Then again, you have to start somewhere, and who knows where this could lead?

Microbial fuel cells aren’t new, of course. If you just want lights, you can skip the electricity altogether.

A Love Letter To The Sphere Computer

[Ben Z] loves the Sphere computer, a very early entry in the personal computer boom of the mid 1970s. The 6800 CPU was unique in its day that it was a full system — at least in theory. If you could afford the whole system, you got a nice case with a keyboard and a memory-mapped display board. You can see a great video tour of the system below the break.

The Sphere suffered from a few problems, none of which were easily foreseeable by its designer. First, the 6800 didn’t get the traction that the 8080-derived CPUs did. Second, the S-100 bus would prove to be popular but that nearly always meant an 8080-type processor in practice. Third, while an all-in-one system was the right idea, it was pricey at the time, and many people would opt for something less expensive even if it had less capability. People also wanted to leverage hardware they may have already had. It was easier to imagine hooking up a surplus TeleType, for example, to a more conventional computer than to a Sphere that expected its own display hardware and keyboard.

Continue reading “A Love Letter To The Sphere Computer”