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 ...


45

Setting and clearing carry, the decimal or interrupt flags is useful: the carry flag because the 6502 offers only add and subtract with carry; the decimal flag because it changes the mode of the processor; and the interrupt flag because it masks or unmasks the maskable interrupt. Conversely, explicitly setting and clearing the other flags mostly isn't ...


44

Yes, BASIC is much slower than assembly for many operations. For an easy example, try out this program on a Commodore 64 or emulator: for i = 1024 to 1984 : poke i,peek(i) or 128 : next You will see each character on the screen reverse, row by row, over the course of ten seconds. By contrast, the exact same routine in machine language inverts the entire ...


44

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 ...


44

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 ...


33

The simple answer is that early operating systems for the systems you mention did not provide those features. Apple DOS, for example, makes no use of interrupts, and has no concept of processes or memory protection. Nor does DOS have any concept of hardware drivers, as it includes support to drive the Disk II (a deep assumption in DOS) and nothing else. ...


28

For "home" computer systems such as the Apple II, the "operating system" wasn't anything like a modern one with processes and device drivers and so on; by the standards of modern OSes there wasn't really one at all. As a warning: all these explanations (long as they are) are for the most part considerably simplified. This answer is ...


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 ...


27

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 ...


26

There is simply no need for setting Overflow. The same is as well true for Negative/Sign and Zero. No operation will be influenced by any of them, it's only used to signal an overflow during ADC and SBC (well, and BIT for testing bit#6). In fact, the question is rather, why there is a CLV present, as there is no reason, within the boundaries of the ...


25

On the BBC Micro, the byte after the BRK instruction held the error number, followed by the error message string terminated with 0x0D. CALLing the address of the BRK instruction would cause an error to be raised. Update with example, as a runnable BBC BASIC program: 10 DIM b% 32 20 ?b%=0: REM BRK 30 ?(b%+1)=42: REM Error number 42 40 $(b%+2)="StackExchange"...


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 ...


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 ...


19

The BRK instruction on the MOS 6502 seems to be one of the more ill-documented features of the processor. [...] Given the lack of documentation about this It is documented quite well and in depth in the corresponding MCS 6500 Microcomputer Family Programming Manual of January 1976 (and all follow ups). Check page 144 and after for description, reasoning ...


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 ...


17

We talk about the late 1970s and mainstream 6502 machines, right? It wasn't so much that programs run under OS control as that OS was a support function to Programs. More like what we would today see as a standard library with routines supporting simple I/O abstraction plus basic file handling on the user side and hard coded drivers within. Some, like ...


16

Most implementations of BASIC for 8-bit home computers were interpreters, and in that sense they're similar to the standard versions of Python. You could typically expect simple programs to run 100 times slower in BASIC than in assembly of ordinary quality. However, it would normally take much less time to write that program in BASIC than in assembly. For ...


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 ...


15

Does the Commodore CDTV-CR contain a 65C02 for some reason? Yes, but it's a rather plain (NMOS) 6500 core. Or, if it's emulating actual hardware, where is the 65C02? Hiden in a CSG 6500/1 microcontrollers (*1) All Amigas used variations thereof. They are basically a 6503 CPU (*2) plus a 6531 RRIOC(*3) with RAM halved to 64 Byte (*4) joint in a single ...


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

The typical circa-1980 8-bit CPU provided almost no support for modern operating system features. It was often possible to add such support using external logic, but very few machines actually did so because it would have added costs to the hardware with little practical benefit. Even many minicomputers of the time left those features out, at least in the ...


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 ...


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