The 8051 was an 8-bit Harvard-architecture microcontroller first put out by Intel in 1980. They’ve since discontinued that line, but it lives on in the low-cost STC8 family of chips, which is especially popular in Asia. They’re cheap as, well, chips — under 1$ — but lack compatibility with modern toolchains. If you’re happy with C, then you’re fine, but if you want to plus-plus it up and use all those handy-dandy shortcuts provided by the Arduino ecosystem, you’re out of luck. Or rather, you were, until [Bùi Trịnh Thế Viên] aka [thevien257] came up with a workaround.
The workaround is delightfully Hack-y. One could, conceivably, port a compiler for Arduino’s Wiring to the 8051, but that’s not what [Viên] did, probably because that would be a lot of work. There isn’t even a truly modern toolchain to put plain C on this chip. Instead, [Viên] started with rv51, a RISC-V emulator written in 8051 assembly language by [cryozap]. RISC-V is a lot easier to work with and, frankly, a more useful skill to build up.
Now emulation does come with a cost: 8kB of flash memory and a 100x to 1000x slowdown in the emulated application code. For that reason, anything timing critical, like interrupts, should probably be handled the old-fashioned way. He’s targeting the STC8H8K64U specifically, so if you happen to have other STC8-based dev boards lying around, you’ll have some extra work ahead of you.
Of course, you can get ultra-cheap microcontrollers that are natively RISC V already– and they’re good enough to act as microcomputers of the era the 8051 hails from, so this hack is likely going to stay fairly niche. Still, if you’re in that niche, teaching an 8051 to speak RISC might be a handy trick to have in your back pocket.

>100x to 1000x slowdown
so it’s about as useful as a substitute toilet seat made from raw shrimps
after taking a dump not only you have to wipe, but also scrape squished dead fish from your buttocks
One of those times I’d rather not have a vivid imagination. It’s too late though…
Crustaceans, not fish.
Yes that slowdown is very severe.
That said, could this 8051 method, or perhaps betetr the C toolchain which apparently already exists for 8051, ever be used to flash “arduino” (the basic bits of underlying C and C-language, non-assembly, port mamipulations) code to an SiLabs C8051F850 series chip?
Thanks
Most projects don’t need the speed. Why would you ever check the state of a door switch more than 50 times per second?
In other words, just use a BASIC interpreter. Better suited for these 8 bitters anyway.
A car, that not only runs on gas, but also needs six couples of heavy horses and a fox in order to move very slowly.
8051 should finally die. Even Amish EEs use MSP430 nowadays.
I like ancient 8052-AH BASIC chip!
The BASIC interpreter is very sophisticated and usable for industry and automation (not a toy).
Because the code is released, it can be run on other 805x platforms, too.
More information:
https://en.wikipedia.org/wiki/Intel_MCS-51
https://hackaday.io/project/194587-single-chip-computer
I’d rather use rv51 to run rust. Basic’s had it’s day in the sun already.
Can it run doom?
The 8051 is what they used in the keyboards when PCs couldn’t even run DOOM. So, no, probably not.
i8042 was used in PC/ATs, I think.
On XTs, the motherboard had some parallel port chip and no microcontroller yet.
With DLSS you could get 40-50 FPS.
Try for DLSS5, you might be able to count the fake hair out of the demon’s nose on that 8051
Ha ha, love it!!
First thought: “Oh man, that title…” second thought: “oh Jesus was that really twenty five years ago…”
Inconceivable!
Using the SDCC C compiler with a C++ to C pre-processor is likely a more feasible solution. But still a funny project.
An even more feasible solution is to simply port your C++ code to C. Don’t get me wrong, I prefer C++ to everything but for some embedded processor, you must aggressively remove wasted bytes.
SDCC is the ideal 8051compiler and as I did with the CC2533, you can easily implement the setup{} and loop{} structure.
Serisman has a simple “core” on github for the SmartRrsponsePE which can be hacked to support other uC implementations.
http://github.com/serisman/Smart-Response-PE/tree/master
-and-
I have some example code and batch files which simplify the Arduino’ish C-code structure on my hackaday.io pages:
http://hackaday.io/project/191722-rpn-integer-calculator-from-smart-response-pe
Experimenters should not be put off between “C” and C++, it is not really a big deal and not using the ArduinoI-DE just mean one has to use the gray matter in their heads; think of it as a retreat from the black-box concept and a opportunity to understand the processes for compiling, linking, and creating a binary file for uploading to the uC… A back to nature moment.
Why not just program it directly in C? You would be using old tools, but they worked pretty well back in the day. There’s even an open source C compiler for the 8051.
I was playing around with some old code, and I did wonder if it would be feasible to use a cpp to c compiler als a preprocessor for sdcc.
I was discouraged by the inefficiency, but reading this it may be a far more optimal solution.
The 8051 is from an era of assembly language programming, when memory was scarce. Very clever op-codes. It is designed specifically to do well in tight, .ASM
Not well suited to C although it can work of course with major bloat.
“Not well suited to C although it can work of course with major bloat.”
(IMO) This is misleading to newbies since they will take it as gospel, but the compiler (ex: SDCC) and libraries linked really are the determining “bloat” components. Done properly, “C” can be very, very efficient.
From experience, SDCC is remarkably efficient based on my experiments on surplus CC2533 uC hardware. I have 3 examples on:
http://hackaday.io/rayburne
As a retired IT Systems Architect, real magic only happens when one match all the components that makeup a system that satisfies a specific need; in this case the selection and configuration of a tool-chain for the older 8051 core chips.
wouldn’t work with the arduino IDE. with the underlying 8051 riscv implementation there are examples for compiling even rust for this thing.
Using SDCC is a great way to work with those microcontrollers. Their cheap price makes them ideal for through away type of projects. Go for STC8G which come with modern peripherals.
Ahhhh….reality check. The 8051 came out with a Basic interpreter already loaded in it. I have several tubes of 8051’s still in my parts box that I had bought for a project in the 90’s using the on board basic. I actually worked quite well, until superseded. I still have a soft spot for the 8051 and it’s basic interpreter.
You’re going to have an even harder time with that, considering how stripped down these MCUs are even compared to a late-70’s home computer.
I think if one were to go down that rabbit hole then emulating an early ATmega series microcontroller might be a better candidate for a modern 8051 – possibly approaching real AVR clock speeds.