The ALU in the 6502

A query and response from the fediverse, worth preserving here I think:

Vertigo #$FF@vertigo@hackers.town

@EdS … I was looking for a detailed explanation of how the ALU worked on the 6502, but can no longer find it. I tried Ken Shirriff’s blog, but he doesn’t appear to have such an article…

To which I was able to reply:

There are analyses of the 6502 ALU… I can’t presently find the exact one I want. But happy to help answer your questions, for example see
ALU design, Part 2
particularly
NMOS 6502 ALU
and others nearby - see Dieter’s homepage

Links in this 6502.org forum post might be helpful
Input registers for the 6502’s ALU?

The patent US 3991307 might be handy

Here’s an image from the patent:

Alt text:

Image of Sheet 2 of 3 from US Patent 3,991,307 dated Nov 9, 1976.

Labelled Fig 2a.

Shows two bits from the 6502 ALU, each with 5 complex logic gates, two simple gates, three inverters. Also four pass transistors on the left side, and a pulldown transistor, connected to 5 vertical common control wires.

Bits 0 and 1 of busses labelled A and B run from left to right, with A above and B below each bit slice.

On the right there are 5 further pass transistors controlled by their respective vertical control lines.

More than two busses are connected on the right hand side.

The carry chain is shown connecting adjacent bitslices.

The logic gates for the odd and for the even bitslices are different to accommodate the inversion of the carry.

An additional connection runs from the higher to the lower numbered bit slices to allow for right shifts.

Edit to add: a blog post on the topic
The MOS 6502’s Parallel Binary/BCD Adder patent – SusaNET

Edit to add: another related post on the 6502 forum.

Edit to add: a series of related blog posts, unfortunately without pictures.

The original query was about the deadness of the visual6502 wiki, to which I responded

There’s a reasonable subset on the wayback machine:
All pages - VisualChips

Jeff Berkowitz has put together a beta version of a reconstruction of the visual6502 wiki, in the form of static web pages based on a github repository here

There’s another visual6502 wiki resurrection here on NesDev

(ref also here)

5 Likes