Videos Teach Bare Metal RP2040

When we write about retrocomputers, we realize that back in the day, people knew all the details of their computer. You had to, really, if you wanted to get anything done. These days, we more often pick peripherals and just assume our C or other high level code will fit and run on the CPU.

But sometimes you need to get down to the bare metal and if your desire is to use bare metal on the RP2040, [Will Thomas] has a YouTube channel to help you. The first video explains why you might want to do this followed by some simple examples. Then you’ll find over a dozen other videos that give you details.

Any video that starts, “Alright, Monday night. I have no friends. It is officially bare metal hours,” deserves your viewing. Of course, you have to start with the traditional blinking LED. But subsequent videos talk about the second core, GPIO, clocks, SRAM, spinlocks, the UART, and plenty more.

As you might expect, the code is all in assembly. But even if you want to program using C without the SDK, the examples will be invaluable. We like assembly — it is like working an intricate puzzle and getting anything to work is satisfying. We get it. But commercially, it rarely makes sense to use assembly anymore. On the other hand, when you need it, you really need it. Besides, we all do things for fun that don’t make sense commercially.

We like assembly, especially on platforms where most people don’t use it. Tackling it on a modern CPU is daunting, but if you want to have a go, we know someone who can help.

Continue reading “Videos Teach Bare Metal RP2040”

Bootstrapping The Old Fashioned Way

The PDP-11, the Altair 8800, and the IMSAI 8080 were some of the heroes of the computer revolution, and they have something in common — front panel switches, and a lot of them. You probably have a fuzzy idea about those switches, maybe from reading Levy’s Hackers, where the painful process of toggling in programs is briefly described. But how exactly does it work? Well thanks to [Dave Plummer] of Dave’s Garage, now we have a handy tutorial. The exact computer in question is a reproduction of the IMSAI 8080, the computer made famous by a young Matthew Broderick in Wargames. [Dave] managed to score the reproduction and a viewer saved him the time of assembly.

The example program is a Larson Scanner, AKA making an strip of lights push a pulse of light across the strip. [Dave] starts with the Assembly code, a scant 11 lines, and runs it through an assembler available online. That gives us machine code, but there’s no hex keypad for input, so we need those in 8-bit binary bytes. To actually program the machine, you set the address switches to your start-of-program location, and the data switches to your first byte. The “deposit” switch sets that byte, while the “deposit next” switch increments the address and then stores the value. It means you don’t have to key in an address for each instruction, just the data. Get to the end of the program, confirm the address is set to the start, and flick run. Hope you toggled everything in correctly. If so, you’re rewarded with a friendly scanner so reminiscent of 80s TV shows. Stick around after the break to see the demonstration!
Continue reading “Bootstrapping The Old Fashioned Way”

Homebrew An OS From Scratch? Snowdrop Shows How It’s Done

Ever wondered what it would take to roll your own OS? [Sebastian]’s Snowdrop OS might just provide you with some insight into that process, and maybe even some inspiration.

[Sebastian] created Snowdrop completely from scratch, using only x86 assembly language. It’s more than just bare-bones, and boasts a number of useful utilities and programs including a BASIC interpreter and linker (for creating standalone BASIC executables.) That’s not even touching on the useful essentials, like multitasking and a GUI framework. There are even a number of resources specifically for making game development easier. Because as [Sebastian] puts it, what’s a operating system without games?

Interested in giving Snowdrop a try, or peek at the source code? The binaries and sources section has all you need, and the other headings at the top of the page will send you to the various related goodies. If you have a few minutes, we recommend you watch a walkthrough of the various elements and features of Snowdrop in this video tour (embedded after the page break.)

Snowdrop is an ambitious project, but we’re not surprised that [Sebastian] has made it work; we’ve seen his low-level software skills before, with his fantastic efforts around the classic stand-up arcade game, Knights of the Round.

Continue reading “Homebrew An OS From Scratch? Snowdrop Shows How It’s Done”

AVX-512: When The Bits Really Count

For the majority of workloads, fiddling with assembly instructions isn’t worth it. The added complexity and code obfuscation generally outweigh the relatively modest gains. Mainly because compilers have become quite fantastic at generation code and because processors are just so much faster, it is hard to get a meaningful speedup by tweaking a small section of code. That changes when you introduce SIMD instructions and need to decode lots of bitsets fast. Intel’s fancy AVX-512 SIMD instructions can offer some meaningful performance gains with relatively low custom assembly.

Like many software engineers, [Daniel Lemire] had many bitsets (a range of ints/enums encoded into a binary number, each bit corresponding to a different integer or enum). Rather than checking if just a specific flag is present (a bitwise and), [Daniel] wanted to know all the flags in a given bitset. The easiest way would be to iterate through all of them like so:

while (word != 0) {
  result[i] = trailingzeroes(word);
  word = word & (word - 1);
  i++;
}

The naive version of this look is very likely to have a branch misprediction, and either you or the compiler would speed it up by unrolling the loop. However, the AVX-512 instruction set on the latest Intel processors has some handy instructions just for this kind of thing. The instruction is vpcompressd and Intel provides a handy and memorable C/C++ function called _mm512_mask_compressstoreu_epi32.

The function generates an array of integers and you can use the infamous popcnt instruction to get the number of ones. Some early benchmark testing shows the AVX-512 version uses 45% fewer cycles. You might be wondering, doesn’t the processor downclock when wide 512-bite registers are used? Yes. But even with the downclocking, the SIMD version is still 33% faster. The code is up on Github if you want to try it yourself.

NASA Hardware Techniques: Soldering Space Electronics Like It’s 1958

[PeriscopeFilms] on YouTube has many old TV adverts and US government reels archived on their channel, with some really interesting subjects to dive in to. This first one we’re highlighting here is a 1958 film about NASA Soldering Techniques (Video, embedded below), which has some fascinating details about how things were done during the Space Race, and presumably, continue to be done. The overall message about cleanliness couldn’t really be any clearer if they tried — it’s so critical it looks like those chaps in the film spend far more time brushing and cleaning than actually wielding those super clean soldering irons.

Of particular note are some of the details of wire stripping and jointing with components, such as the use of a hot-wire device to remove the insulation from wire, rather than use the kind of stripper we have lying around that cuts into the insulation and slightly distorts the wire in the process. That just won’t do. If they did have to use a cutting-type stripper, it must be precisely the right size for job, and calibrated daily.

The road to the Moon is paved with calibrated wire strippers.

When soldering a pre-tinned wire to a leaded component, a clamp is required to prevent movement of the wire, as is a thermal shunt on the component lead to protect the delicate component from excess heat. They even specify how much to wrap a wire around a terminal to be soldered, never bending the wire more than 180 degrees.

The bottom line in all this is, is that the work must be as perfect as is possible, as there is very little chance of sending someone up to fix a dodgy soldering job, once the assembly is hurtling around the planet. They call it too much of a science to be called an art and too much art to be called a science, and we can sure appreciate that.

As you would expect (and it’s not exactly a big secret) NASA has some very exacting standards for assembly of all hardware, like this great workmanship standard, which is well worth studying. Soldering is an important subject for many of us, we’ve covered the subject of solder metallurgy, as well as looking at how ancient hardware hackers soldered without the benefit of much modern knowledge.

Continue reading “NASA Hardware Techniques: Soldering Space Electronics Like It’s 1958”

Old Casio Calculator Learns New Tricks

[George Stagg] recently found himself stung by the burden of free time while in lockdown. Needing a project to keep him occupied, he decided to upgrade his 90s Casio CFX-9850G calculator to run custom machine code.

All [George] really wanted was for his vintage calculator to understand Reverse Polish Notation (RPN). The calculator in question can already run its own version of BASIC, however the bespoke Hitachi CPU struggles performance-wise with complex programs, and wouldn’t be a realistic way of using RPN on the calculator. An RPN interpreter written in assembly language would be much faster.

The first step in cracking this calculator wide open was a ROM dump, followed by writing a disassembler. Incredibly, the MAME framework already featured a ‘partial implementation’ of the calculator’s CPU, which was a much needed shot in the arm when it came time to write a full-featured emulator.

With the entire calculator emulated in software, the plan from here involved replacing one of the BASIC commands in ROM with new code that would jump to an address in RAM. With 32KB of RAM there ended up being plenty of room for experimentation, and uploading a program into RAM was simplified by using Casio’s original backup software to dump the RAM onto a PC. Here, the contents of RAM could be easily modified with custom code, then uploaded back into the calculator.

With RAM to burn, new routines were created to write custom characters to the screen, and a new font was created to squeeze more characters onto the display than normal. [George] ended up porting a Forth interpreter, which defaults to RPN style, to finally achieve his humble objective. He also managed to get a version of Conway’s Game Of Life running, check out the video after the break.

We can’t get enough of our calculator hacks here, so make sure to check out the CPU transplant on this vintage Soviet calculator.

Continue reading “Old Casio Calculator Learns New Tricks”

Reliving Second-Hand Nostalgia With The PDP-11

Levy’s Hackers: Heroes of the Computer Revolution is something like required reading for the hacker subculture, and Hackaday by extension. The first section of that book is all about early hackers and their adventures with the PDP-1 at MIT. The PDP-11 has earned a special place in hacker history for being the minicomputer used to write the first Unix. We’re always amazed to find how many of our readers have stories about programming PDP microcomputers, usually the PDP-11. Those of us young enough to have missed out on the PDP experience often have something of a second-hand nostalgia for the old machines. An exceptionally detailed article over at Ars Technica promises to get us started reliving the glory days, even if it is for the first time.

It turns out that there’s an emulator for the old minicomputers, the History Simulator, abbreviated SimH. The article gives step-by-step instructions to get the emulator running, booting Unix 2.11 on a virtual PDP-11. The fun doesn’t stop there. The write-up includes an intro the the PDP-11 hardware, and a crash-course to assembly programming for the beast. It’s a great look at how the stack, branching, and subroutines work under the hood. Most of it still applies to computing today, so it really is worth the read.

Looking for more PDP-11 lore? Check out our coverage of DEC’s history.

The image above is “PDP-11” by ToastyKen, and is licensed under CC BY 2.0