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

Pick and place reels

Pick And Place Hack Chat

Join us on Wednesday, February 9 at noon Pacific for the Pick and Place Hack Chat with Chris Denney!

We in the hacker trade are pretty used to miracles — we make them all the time. But even the most jaded among us has to admit that modern PCB assembly, where components that could easily hide under a grain of sand are handled by robots, borders on witchcraft. The pick and place machines that work these wonders not only have to hit their marks accurately and precisely, but they also do it at blinding speeds and for days on end.

join-hack-chatLuckily, even those of us who design circuits for a living and depend on PCB assembly services to realize those designs can, at least to some degree, abstract the details of the pick and place phase of the process away. But making it “just work” isn’t a trivial task, and learning a little bit about what it takes to do so can make us better designers. Plus, it’s just plain cool to watch a pick and place do its thing. And to dive a little deeper into pick and place, Chris Denney, CTO of Worthington Assembly and co-host of “Pick, Place, Podcast” will stop by the Hack Chat. If you’ve ever wondered about the inner workings of PCB assembly and the role pick and place plays in it, or if you’re looking for tips on how to optimize your layouts for pick and place, this is one you won’t want to miss!

Our Hack Chats are live community events in the Hackaday.io Hack Chat group messaging. This week we’ll be sitting down on Wednesday, February 9 at 12:00 PM Pacific time. If time zones have you tied up, we have a handy time zone converter.

Continue reading “Pick And Place Hack Chat”

The Linux X86 Journey To Main()

Have you ever had a program crash before your main function executes? it is rare, but it can happen. When it does, you need to understand what happens behind the scenes between the time the operating system starts your program and your first line of code in main executes. Luckily [Patrick Horgan] has a tutorial about the subject that’s very detailed. It doesn’t cover statically linked libraries but, as he points out, if you understand what he does cover, that’s easy to figure out on your own.

The operating system, it turns out, knows nothing about main. It does, however, know about a symbol called _start. Your runtime library provides this. That code contains some stack manipulation and eventually calls __libc_start_main which is also provided by the library. Continue reading “The Linux X86 Journey To Main()”