80386 Multiplication and Division

Posted by nand2mario 14 hours ago

Counter86Comment30OpenOriginal

Comments

Comment by bsaul 10 hours ago

Is there a rational explanation on why there seems to be a HN article answering the weirdest questions i had in my mind just a few days ago ? Only yesterday i wondered how did CPU performed division. I didn't ask or type anything about it. It was just in my mind. And now this.

Are we part of a collective mind ? Do social networks algorithms shape society that deeply that we all end up having about the same random thoughts ?

This is really scary in a way.

Comment by aidos 10 hours ago

Not sure if it has a name but often there’s a trend of “one thing leads to another” related articles on the HN front page.

Yesterday there was something similar that might have planted a seed in your mind like it did for other people.

https://news.ycombinator.com/item?id=46735133

Comment by nand2mario 9 hours ago

Right. Or it could be frequency illusion. Once you become aware of something, it appears to be more frequent:

https://en.wikipedia.org/wiki/Frequency_illusion

Comment by bsaul 3 hours ago

I definitely noticed this trend of article chaining, bu it must have been something else in this case, because i have absolutely 0 memory of seing that post yesterday. Actually, i think my thought came from an instagram video in my feed of a guy showing human division algorithm using sticks on a whiteboard.

Comment by y42 8 hours ago

or probably just some kind of preference/selection bias.

You own a red Mercedes now and suddenly you see only red Mercedes' on the streets.

Comment by Guestmodinfo 4 hours ago

I may have the answer. This website nand2mario and something like this article was here on HN a while ago. Maybe a month or two months ago. So maybe then you were busy and didn't read it fully but your mind caught it somehow from HN or coworkers/friends and now when you are relaxed you can register the stuff nicely. Typing 80386 in the search doesn't gets me that exact post.

Comment by hybrid_study 5 hours ago

This is probably just availability bias / frequency illusion at work. Thinking about something once makes the brain suddenly notice it everywhere. The coincidences stick, but all the misses don’t. Feels like magic, but it’s just how attention and memory play tricks.

Comment by jakzurr 5 hours ago

No, no, no.

I think it's actually really simple. We tech nerds sometimes think a lot the same way.

Comment by hahahahhaah 10 hours ago

The mind data-mines.

Comment by userbinator 10 hours ago

No discussion of these instructions on the 386 would be complete without mentioning that early revisions had a bug in the 32-bit multiply: https://retrocomputing.stackexchange.com/questions/17803/int...

I wonder if anyone outside of Intel has discovered the actual bug in the circuitry yet.

Comment by st_goliath 7 hours ago

Yes, one can only hope Ken Shirriff eventually happens to come across one of those models, but I guess they are probably very rare these days.

Besides the multiplication, the 386 had quite a number of teething problems[1], including occasionally broken addressing modes, unrecoverable exceptions, virtual address resolution bugs around the 2G mark, etc...

A while ago, there was also an article posted here that analyzed the inner workings of the Windows/386 loader[2]. Interestingly, Windows simply checks a pair of instruction (XBTS/IBTS) that early 386 steppings had, but was later removed, raising an invalid opcode exception instead.

Raymond Chen also wrote a blog post describing a few workarounds that Windows 95 had implemented[3].

[1] https://www.pcjs.org/documents/manuals/intel/80386/

[2] https://virtuallyfun.com/2025/09/06/unauthorized-windows-386...

[3] https://devblogs.microsoft.com/oldnewthing/20110112-00/?p=11...

Comment by kens 7 hours ago

From what I've read, the 386 multiplication bug was a semi-analog problem, so the fix was probably making a transistor larger. As a result, it would probably be hard to find the fix on the die and wouldn't be as interesting as, say, the Pentium division bug.

Comment by FarmerPotato 6 hours ago

This reminds me of a problem from undergrad computer architecture: how can you validate the multiplier without checking all possible N squared inputs? (Which would take forever.)

I read later in a TI DRAM report about which bit pairs to exercise, based on proximity in silicon layout, to verify the part. I suppose something like that to stress-test the ALU.

Comment by nand2mario 4 hours ago

Author here. Happy to discuss the technical details. The broader goal is to understand the 80386 microcode and hardware, and build an FPGA core around it, similar to what was already done for the 8086.

Comment by rep_lodsb 9 hours ago

The 80186 and NEC Vxx chips - and of course also the 286 - could already do mul/div in one cycle per bit (+ some overhead for the microcode). What they didn't have was the early-out optimization.

The three-operand form of IMUL also already existed on those processors.

>This wasn't just an incremental upgrade—it was the foundation that would carry the PC architecture for decades to come.

AI?

Comment by ack_complete 1 hour ago

The timeline for fast multiplies is also a bit off, IMUL was already 4c latency / 1c throughput on the Pentium Pro (1995) and Pentium II (1997). Pretty sure IMUL was also only a few cycles on the AMD K6 (1997). Though Intel slowed it back down again in the Pentium 4, until they reverted back to the P6 architecture in the Pentium M.

Comment by csmantle 9 hours ago

> AI?

Probably not; this point is well justified by both theory and practice. Supporting suitably larger operands is indeed what naturally comes following the increase of computation demands.

One point I do differ from the author is that register width don't necessarily correlate with the size of address space. Even 8bit machines can address a large space by splitting apart the logical address and using multiple registers. Likewise, having a wide register does not imply the same address width.

Comment by jecel 1 hour ago

The naming of processor sizes is the subject of debate. I call a "pure 8 bit processor" one that has 8 bits for both data and addresses. Like the Kenbak-1. But these are so rare and educational rather than practical that it is very reasonable to call hybrid 8 bit / 16 bit processors just "8 bit".

This use of sloppy terms shouldn't make us forget that they are using an address extension trick, just like all those 16 bit processors that wanted to go beyond 64KB (for byte addressed such as the PDP-11, Z8000 or 8086) or 128KB (for word addressed, like the Xerox Alto's modified Data General Nova model).

Comment by direwolf20 7 hours ago

The writing style appears to be AI.

Comment by FarmerPotato 6 hours ago

I see it all over the article. Occasionally there is a more human voice. (See that single dash? The rare use of "I"?) The overall structure resembles a AI response to "explain this code snippet" prompt.

Comment by 9 hours ago

Comment by Aardwolf 4 hours ago

> It would go on to run Windows 3.0, Windows 95, early Linux

That feels like a stretch :) Maybe it indeed ran on it, but Pentium was available when Windows 95 was released and it was probably far more likely to be sold along with such new Pentium multimedia machines, than someone getting it for their old 386. But Windows 3.11 was its exact match!

Comment by LeFantome 3 hours ago

As somebody that was around at the time, this is not at all a stretch.

First, Linux was created FOR the 386. Linus Torvalds had one and wanted to unlock its power.

As you say, Windows 3.0 is certainly no stretch.

That leaves only Windows 95. The minimum spec at launch was a 386 with 4 MB of RAM. Realistically, you needed 8 MB to do anything.

Here is an article from 1993 saying that manufactures are beginning to drop the 386 from their product lines. That is, this is when people stopped being able to buy 386 machines brand new.

https://books.google.com/books/about/InfoWorld.html?id=2zsEA...

The 486 was the dominant chip in 1993 but there were still a lot of 386 machines being sold to that point when.

When Windows 95 shipped, people would certainly have been trying to run it on those machines.

When Windows 95 was released, people famously lined up to buy it like they were getting tickets to a rock concert. It was not just sold with new hardware. Back then, it was normal for people to pay money to buy a new operating system to run on hardware they already owned.

Of course Windows 95 certainly helped sell Pentiums. Pentium would have dominated new sales but a typical PC in service in 1995 would have been a 486 and there were still plenty of 386 machines in use.

Comment by saltcured 2 hours ago

A lot of (older than me) enthusiasts I knew got an MSDN subscription even though they weren't really developing apps for Windows. This gave them a steady stream of OS releases on CD-ROMs, officially for testing their fictional apps. So, they were often upgrading one or more systems many times rather than buying new machines with a bundled new OS.

Personally, yeah, I had Windows 3.0/3.11 on a 386. I think I may have also put an early Windows NT (beta?) release on it, borrowing someone's MSDN discs. Not sure I had got value from it except seeing the "pipes" software OpenGL screensaver. Around '93-94, I started using Linux, and after that it was mostly upgrading hardware in my Linux Box(en) of Theseus.

I remember my college roommate blowing his budget upgrading to a 180 MHz Pentium Pro, and he put Windows 95 on it. I think that was the first time I heard the "Start me up!" sound from an actual computer instead of a TV ad.

After that, I only encountered later Windows versions if they were shipped on a laptop I got for work, before I wiped it to install Linux. Or eventually when I got an install image to put Windows in a VM. (First under VMware, later under Linux qemu+kvm.)

Comment by deaddodo 4 hours ago

Windows 95 was Microsoft's biggest commercial hit at that point. Selling 40m copies in its first year.

There's no doubt that it went in to upgrade plenty of 386s/486s until the owners upgraded their hardware.

Comment by vardump 4 hours ago

You needed at least 12 MB RAM to run Windows 95 smoothly. There were plenty of 8 MB systems that really really struggled. Even booting up was a swap fest.

I remember immediately upgrading to 12 MB. 8 MB was painful.

Not all 386 class systems could be upgraded to 12 MB or more.

Comment by EvanAnderson 4 hours ago

I did a ton of upgrades from 3.1 to Windows 95 in late 1996 and early 1997 on 386 and 486 machines with 4MB of RAM. I still have a "mark" from the tedium. Some of the machines didn't have a large enough hard drive to store a copy of the setup files (the "CAB files") so until the company issued me a ZIP drive I had to do "the floppy shuffle" with 20-ish disks.

It ran like crap with 4MB of RAM but it did run. Opening anything much resulted in paging.

Comment by vardump 3 hours ago

Your mileage may vary. I remember 4 MB booting, but being absolutely useless.

8 MB was still swapping all the time, you couldn't really run much beyond some simple software.

12 MB was finally enough to do something productive, but definitely nothing luxurious.

Comment by TacticalCoder 30 minutes ago

> Maybe it indeed ran on it, but Pentium was available when Windows 95 was released and it was probably far more likely to be sold along with such new Pentium multimedia machines, than someone getting it for their old 386.

I was definitely running Linux on a 486. I even had a big bulky laptop back then but I don't remember what CPU it had: I was running Linux on it too. And my 486 was sharing it's (dial-up, 28.8 or 33.6) Internet connection to the laptop using the PLIP protocol (IP over a parallel cable): I set that up and my brother and I were discovering the Web at the same time. Fun memories.

The jump was not 386 to Pentium. The 486 had its glory days.

Comment by nand2mario 3 hours ago

I was just trying to give a bit of historical context, but apparrently need to be more precise next time! 386 is the beginning of 32 bit. But it's mainly the pentium and 486 that ran Windows 95.

Comment by themafia 11 hours ago

Excellent work. Thank you! Your 486 FPGA project looks pretty neat too.