Here’s How To Build A Tiny Compiler From Scratch

Believe it or not, building a tiny compiler from scratch can be as fun as it is accessible. [James Smith] demonstrates by making a tiny compiler for an extremely simple programming language, and showing off a hello world.

Here’s what happens with a compiler: human-written code gets compiled into low-level machine code, creating a natively-executable result for a particular processor. [James]’ compiler — created from scratch — makes native x64 Linux ELF binary executables with no dependencies, an experience [James] found both educational and enjoyable. The GitHub repository linked below has everything one needs, but [James] also wrote a book, From Source Code to Machine Code, which he offers for sale to anyone who wants to step through the nitty-gritty.

The (very tiny) compiler is on GitHub as The Pretty Laughable Programming Language. It’s tiny, the only data types are integers and pointers, and all it can do is make Linux syscalls — but it’s sufficient to make a program with. Here’s what the code for “Hello world!” looks like before being fed into the compiler:

; the write() syscall:
; ssize_t write(int fd, const void *buf, size_t count);
(syscall 1 1 "Hello world!\n" 13)
0

Working at such a low level can be rewarding, but back in the day the first computers actually relied on humans to be compilers. Operators would work with pencil and paper to convert programs into machine code, and you can get a taste of that with a project that re-creates what it was like to program a computer using just a few buttons as inputs.

It’s DOOM, But In Teletext

We’ve seen the 1993 id Software classic DOOM running on so many pieces of unexpected hardware, as “Will it run DOOM?” has become something of a test for any new device. But will it run in the circuitry of a 1970s or 1980s TV set? Not quite, but as [lukneu] has demonstrated, it is possible to render the game using the set’s inbuilt Teletext decoder.

Teletext is a technology past its zenith and which is no longer broadcast in many countries, but for those unfamiliar it’s an information service broadcast in the unseen lines hidden in the frame blanking period of an analogue TV transmission. Its serial data packets can contain both pages of text and rudimentary block graphics, and we’re surprised to learn, can include continuous streams to a single page. It’s this feature that he’s used, piping the game’s graphics as a teletext stream which is decoded by the CRT TV and displayed as a playable if blocky game.

Delving further, we find that DOOM is running on a Linux machine on which the teletext stream is created, and the stream is then piped to a Raspberry Pi which does the encoding on to its composite video output. More powerful versions of the Pi can run both processes on the same machine. The result can be seen in the video below, and we can definitely say it would have been mind-blowing, back when DOOM was king. There are plans for further refinement, of which we’d say that color would be the most welcome.

Continue reading “It’s DOOM, But In Teletext”

A Vintage Polaroid Camera Goes Manual

There once was a time when all but the most basic of fixed focus and aperture cameras gave the photographer full control over both shutter speed and f-stop. This allowed plenty of opportunity to tinker but was confusing and fiddly for non-experts, so by the 1960s and ’70s many cameras gained automatic control of those functions using the then quite newly-developed solid state electronics. Here in 2023 though, the experts are back and want control. [Jim Skelton] has a vintage Polaroid pack film camera he’s using with photographic paper as the film, and wanted a manual exposure control.

Where a modern camera would have a sensor in the main lens light path and a microcontroller to optimize the shot, back then they had to make do with a CdS cell sensing ambient light, and a simple analog circuit. He considered adding a microcontroller to do the job, but realized that it would be much simpler to replace the CdS cell with a potentiometer or a resistor array. A 12-position switch with some carefully chosen resistor values was added, and placed in the camera’s original battery compartment. The final mod brought out the resistors and switch to a plug-in dongle allowing easy switching between auto and switched modes. Result – a variable shutter speed Polaroid pack camera!

Sadly the film for the older Polaroid cameras remains out of production, though the Impossible Project in the Netherlands — now the heirs to the Polaroid name — brought back some later versions and have been manufacturing them since 2010. Hackers haven’t been deterred though and have produced conversions using Fuji Instax film and camera components, as with this Polaroid portrait camera, and [Jim]’s own two-camera-hybrid conversion.

A 4-Player Arcade Hidden Inside A Coffee Table

[Ed] from 50% Awesome on YouTube wanted to build a retro gaming system with a decent screen size, but doesn’t have a great deal of space to site it in, so a good compromise was to make a piece of useful furniture and hide all the fun parts inside.

Building an arcade machine usually involves a lot of wiring

This video two-part build log shows a lot of woodwork, with a lot of mistakes (happy accidents, that are totally fine) made along the way, so you do need to repeat them. Essentially it’s a simple maple-veneered plywood box, with a thick lid section hosting the display and some repositioned speakers. This display is taken from a standard LG TV with the control PCB ripped out. The power button/IR PCB was prised out of the bezel, to be relocated, as were the two downwards-facing speakers. The whole collection of parts was attached to a front panel, with copious hot glue, we just hope the heavy TV panel was firmly held in there by other means!

Continue reading “A 4-Player Arcade Hidden Inside A Coffee Table”

A Look Inside A Vintage Aircraft Altimeter

There’s a strange synchronicity in the projects we see here at Hackaday, where different people come up with strikingly similar stuff at nearly the same time. We’re not sure why this is, but it’s easily observable, with this vintage altimeter teardown and repair by our good friend [CuriousMarc] as the latest example.

The altimeter that [Marc] dissects in the video below was made by Kollsman, which is what prompted us to recall this recent project that turned a jet engine tachometer into a CPU utilization gauge. That instrument was also manufactured by Kollsman, but was electrically driven. [Marc]’s project required an all-mechanical altimeter, so he ordered a couple from eBay.

Unfortunately, thanks to rough handling in transit they arrived in less than working condition, necessitating the look inside. For which we’re thankful, of course, because the guts of these aneroid altimeters are quite impressive. The mechanism is all mechanical, with parts that look like something [Click Spring] would make for a fine timepiece. [Marc]’s inspection revealed the problem: a broken pivot screw keeping the expansion and contraction of the aneroid diaphragms from transmitting force to the gear train that moves the needles. The repair was a little improvisational, with 0.5-mm steel balls used to stand in for the borked piece. It may not be flight ready, but it worked well enough to get the instrument back in action.

We suspect that [Marc] won’t be able to leave well enough alone on this one, so we’ll be on the lookout for a proper repair. In the meantime, he’ll be able to use this altimeter in the test setup he’s building to test a Bendix air data computer from a 1950s-era jet fighter. Continue reading “A Look Inside A Vintage Aircraft Altimeter”

USB Meets Core Memory In A Vintage ‘Scope

It’s normal today for even relatively modest instruments to have some form of computer control capability over Ethernet or USB. But five decades ago this was by no means a given, and when Tektronix shipped their P7001 digitiser module for their high-end oscilloscopes in 1971, they were initially designed to interface with a minicomputer. Not everybody has a PDP/11 lying around in 2023, but [Holger Lübben] wasn’t fazed by this. He set about creating a USB interface for this ancient piece of test equipment.

At its heart is a Teensy 4.1 which does the job of interfacing with the Tektronix 16-bit bus through a level shifting transceiver. The software for the Teensy comes with some demos, but sadly not the Tek BASIC of the original. We’re particularly impressed with the care to make the card frame for the module resemble as closely as possible an original Tektronix product.

We’re guessing very few of you will have this ancient test module on your bench, but the depth into which he goes over its internal design and programming makes this very much worth a read. If you fancy more vintage Tek goodness, take a look at this current probe.

An IBM PC showing "68000 IBM PC" on its monitor

IBM PC Runs BASIC With Motorola 68000 CPU Upgrade

Although ARM CPUs have been making headway in several areas of computing over the last decade or so, the vast majority of desktop, laptop and server CPUs are still based on the x86 architecture. How that came to be is no secret, of course: IBM chose the Intel 8088 to power its model 5150 PC back in the early 1980s, and since it became the dominant PC platform, everyone else followed suit. But what if IBM’s purchasing department had got a good deal at Motorola instead? [Ted Fried] has been experimenting with that scenario, by equipping an IBM PC with a 68000 CPU.

To be fair, he didn’t use an actual Motorola chip; instead, he emulated a 68k core on a Teensy 4.1 and implemented the 8088’s bus interface on its pins. The emulated core does exactly the same thing an actual CPU would do, while the rest of the computer works the same way it always did – data is stored in the motherboard’s DRAM chips, keystrokes are processed by the standard 8255 chip and progam output is displayed on the monitor through the MDA video card. Continue reading “IBM PC Runs BASIC With Motorola 68000 CPU Upgrade”