Hot answers tagged

78

With a powerful enough microscope, you can see each transistor. Reverse-engineering silicon then boils down to carefully removing each layer (ceramic or plastic to expose the chip, then each metal layer), taking detailed photographs, and figuring out what each part does. For CPUs of the era, this was already possible in the early eighties. Ken Shiriff does ...


49

(More of a memory dump related to Stephens Answer) At a time when ICs were of low complexity (compared today), could you actually see each transistor on the silicon and reverse engineer it? Yes. Just try it yourself. Take some 1980s TTL, like a 7400 - I'm sure you find some on old boards - and crack it open. Usually it separates well from the plastic. Put ...


47

On a typical 6502, Z80, or 68000 system, it's possible to predict very precisely exactly how long a piece of code will take to execute. The same is true, incidentally, of many small microcontrollers produced today. In many cases, this allows some operations to be done more efficiently than would otherwise be possible. For example, if both function-control ...


45

Like all games from that era, cheating and tables. Two 256 byte tables and logarithms gave a 10x speed boost on multiply and divide on Commodore 64 at least. Matrix operations using addition only for fixed known rotation rates. Lazy evaluation. Only convex shapes making hidden line removal simpler and hidden line removal meaning only half the vertices ...


45

One language that was popular on early 8-bit micros, including those that used the 6502 CPU, was Forth. Forth is exceptionally good for this use case, and superior to a C compiler, because Forth can make more efficient use of the 6502's hardware stack. Forth lacks any sophisticated methods of dealing with parameters. Everything is passed through the Forth ...


28

TL;DR: It is all about making one of the most important instructions as performant as possible, while keeping everything manageable for tools at the time (plus a little bit of dogma). The branching is thus the most optimized instruction of the whole 6502 design. In addition, long branches are not really in demand (*1). Of the 116 branches used in the ...


28

It's worth noting what you can see, and what you can't. First, you cannot see any feature that is much smaller than the wavelength of light that you are using. In 1995 I designed a chip for my Master's thesis in 1.2um technology; features are clearly visible under microscope. Features in 0.5um technology might be visible, but by 1997 0.25um technology was ...


24

The designers figured that you'd use X and Y for looping, indexing etc, and use A for adding and subtracting, shifts etc. So they saw a need for INX and INY, but didn't see a enough of a need for an instruction to increment or decrement the accumulator. That's also the reason why X and Y cannot participate in many ALU operations, like adds, shifts, and ...


24

You are in luck. The latest version of the 6502 is still manufactured and sold. You need to search for it by the official manufacturer's product code "W65C02S6TPG-14". Western Design Center (that first "W") licenses the manufacture of the chip to various silicon foundries, which wholesale them to dealers you can buy from online. If you don't use this recent ...


23

But how instructions like DEC, DEX and DEY works ? By adding $FF provided by the precharged internal data bus to the register content. In Detail: The internal databus is precharged with $FF during PHI2 (*1) During the next phase it's loaded into the B register (signal DB/ADD) At the same time the index register is transfered via SB (*/SB) to the A ...


23

Official figures vary, and are sometimes wrong. Evidence indicates that not exceeding to 5-6 microseconds is fine. In Jim Sather's book Understanding the Apple II he has a rough transcript of an interview with Steve Wozniak. On page I-3 they discuss this exact issue. W. I'll tell you about a timing problem that will interest you. My first design for ...


23

This paragraph in Wikipedia really is no candidate for the best entry-of-the-year award. It seems to be comparing Apples with Oranges. (Or rather starts talking about CPUs, then commences on PCs vs. "something else", i.e. system architecture). A comparison of interrupt latency and predictability thereof doesn't make much sense on CPU level - It ...


22

It's the simplicity. Under modern general purpose operating systems, you don't usually have hard real-time guarantees. Too many things are going on. Context switching is slow. Interrupts are slow. The kernel is often not fully pre-emptable. On top of all that, modern hardware incorporates features like speculative execution, extensive pipelining, ...


20

No, you can't substitute; the 6502A was used precisely because it is faster for some things, even when not run at a higher clock rate. Apple IIe Technical Note #2: Hardware Protocol for Doing DMA (starting on page 2 of that PDF) explains this. On page 4 of 9 of the note it says: In the Apple IIe a 6502A, a 2 MHz part is used instead of the 1 MHz 6502 ...


20

I know that the Z80 and the 6502 are very different, but I was wondering if there are any languages on a higher level than assembly which can generate compact and efficient 8-bit machine code by design, and how this was achieved? Well, a prime candidate would be Ada. It was a specific design goal for Ada to produce good code for tiny and 'odd' ...


20

C can be greatly improved as a language for the 6502 and Z80, as well as micros like the PIC and 8051, if one abandons the notion that implementations must provide for recursive subroutine calls, and adds qualifiers for things in zero page or pointers that are limited to accessing such things, and (for the Z80) adds qualifiers to identify objects that are ...


18

For Spectrum BASIC, the routine for Small Integers (16 bit) can be seen on page 179 of the Complete ZX Spectrum ROM Disassembly, where it loops over the sixteen bits of one operand, shifting them into the carry bit, adding successively doubling values to the result value each time the test passes, and testing for overflow if the result doesn't fit in a small ...


16

Multiplying (and dividing) by powers of 2 has always been trivial and fast even for 8-bit processors like Z80 or 6502, with shifting instructions (commonly arithmetic shift left aka ASL). But those processors didn't have a MUL instruction so when it came to non-power of 2 multiplication, it always involved shifting, testing bit and adding shifted result if ...


14

On the 6502, the designers did this for efficiency. This is documented in the original MCS 6500 Microcomputer Family Programming Manual: If one considers that the instruction JMP required three bytes, one for OP CODE, one for new program counter low (PCL) and one for new program counter high (PCH) it is seen that jump on carry set would also require ...


13

The hardware reset isn't an optional feature for a reset switch - it's an essential function for starting the CPU up correctly. As the power supply rail rises, circuitry within the CPU, such as the register set, will take on random-ish values. The clock oscillator will unsteadily start working and CPU would start trying to operate before the supply was at a ...


13

Unless I'm mistaken, these mean add/subtract zero. Almost. It means add/subtract zero plus carry. So if the Carry flag is set, then adc #$00 will increment the accumulator by one. Otherwise, the same instruction will leave the accumulator alone. Separately, the adc instruction may also set or clear the carry flags, if incrementing the accumulator meant ...


12

Yes, reverse engineering of chips with a conventional optical microscope in the late 1970s and early 1980s is generally possible. Although of course, there are limitations. Firstly, the number of wiring layers is important - already two layers of metallization and two layers of polysilicon make reverse circuit design much more difficult. Secondly, chip traps ...


10

The most common way to do a general multiplication is the "shift and add" method, where for each bit set in the multiplier you add the multiplicand to the high portion of the result and then shift the result right. Thus, the lowest order bit of the multiplier, if set, contributes 1× the multiplicand to the result after the result has been fully ...


10

In Kick Assembler you can put labels in front of opcode arguments. For example you can write your raster interrupt like: raster_interrupt: lda bgnd_color:#$00 sta $d021 ; rest of interrupt handler and change the color elsewhere in your program with: lda #$01 sta bgnd_color Such labels in front of the argument provide a more compact ...


10

There are three principal reasons: 1: Realtime software demands CPUs whose execution time is highly predictable. That is true mostly of CPUs without speculative features such as caching and dynamic branch prediction. Some modern CPUs (eg. ARM Cortex-R series) are specifically designed to provide this property. 2: Low interrupt latency and overhead, on the ...


9

The 6502 data sheet (archived at http://archive.6502.org/) on page 2 gives the requirements for the RESET line as: After Vcc reaches 4.75 volts in a power up routine, reset must be held low for at least two clock cycles. At this time the R/W and SYNC signals become valid. As I recall from using the chip, a poorly designed POR (power on reset) circuit ...


9

Yes, you're correct. The original 6500 family does not include a Power-On-Reset (POR) circuitry. For reliable startup reset has to be pulled after power up. To avoid unintended execution of random code, it's recommended to keep Reset pulled by default and only release it after power is stabilized. Then again, depending on your setup it may be acceptable ...


9

If one writes opcodes in binary, using the format III-AAA-gg (with "III" generally being "Instruction", "AAA" being "Address mode", and "gg" as "general instruction group"), most instructions of the form III-AAA-01 or III-AA0-10 process addresses the same way using the address mode specified by AAA. The latter group of instructions are read-modify-write ...


9

"Forth" was the first name that jumped to my mind. Another is Action!, an Atari 8-bit-specific language. (Its manual can be found on the Internet Archive.) Action! is a structured Algol-inspired language that borrowed constructs from other languages (in particular, it offered C-like pointers and arrays) and native types that mapped cleanly to the 6502's ...


9

It depends on what you need, really -- and, of course, on where you are. As others have pointed out, the CMOS version of the 6502, the 65C02, is still readily available. Western Design Center sell them through their distributors, notably Mouser, who ship worldwide. There are, however, minor functional differences between the 6502 and the 65C02. If your ...


Only top voted, non community-wiki answers of a minimum length are eligible