Questions tagged [6502]

For 6502 series of processors, including hardware and assembly language questions. Use with [hardware] for the hardware interface in particular.

Filter by
Sorted by
Tagged with
89
votes
8answers
27k views

Why would a NES game use an undocumented 1-byte or 2-byte NOP in production?

Reading the NESdev wiki page on CPU unofficial opcodes, I see a few games use an undocumented 2-byte NOP instuction in production: Puzznic, F-117A Stealth Fighter, and Infiltrator use $89 #i. Beauty ...
56
votes
8answers
13k views

Could you reverse engineer silicon just by looking at it?

I was interested in a recent interview of Masayuki Uemura, one of the engineers who designed the Nintendo Famicom in the early 80s. During initial design phase of the Famicom, one of the first things ...
43
votes
12answers
7k views

What languages are better fit for generating efficient code for 8-bit CPU's than C?

I found Why do C to Z80 compilers produce poor code? very interesting as it pointed out that C (which was designed to be an abstraction of a CPU for porting Unix) was not a very easy language to ...
41
votes
3answers
5k views

What happened to the SEV instruction on the 6502?

The 6502 has a group of opcodes which copy bit 5 from the opcode into one of the status flags. (I know it's not implemented this way, but it looks as though the bit fields are: 2 bits to select the ...
35
votes
5answers
7k views

Why does the 6502 have the BIT instruction?

The 6502 has a bit instruction which copies two of the bits into the N and V flags, pretends to and the byte with the accumulator, but discards the result and only affects Z. I'm having a hard time ...
34
votes
2answers
2k views

Can the two CPUs in a Commodore 128 run at the same time?

The Commodore 128 has two CPUs. One is some variant of the 6502, and the other is a Z80. One CPU is there for compatibility with the Commodore 64 and the other is there presumably to give basic ...
32
votes
4answers
4k views

Why did so many early microcomputers use the MOS 6502 and variants?

Quite a few successful early microcomputers used the MOS 6502 CPU. This included, but was not limited to, systems like the Apple I, Apple II, Commodore PET, and Ataris. A followup known as the MOS ...
31
votes
3answers
3k views

How did Elite do vertex transformation?

In 3D graphics, vertex transformation is the process of converting x,y,z coordinates in 3D space, to x,y coordinates on the screen. According to https://www.khronos.org/opengl/wiki/...
29
votes
2answers
5k views

Why did Sinclair choose the Z80 for its range of home computers?

The Sinclair computers are known for their low cost compared with other computers that were popular in the early 1980s. This is why they had membrane keyboards, or that rubber stuff in the case of the ...
29
votes
1answer
3k views

What is the relative code density of 8-bit microprocessors?

When RAM is at a premium, as it was in the old days, a greater code density of an instruction set can be a substantial advantage. (Click saver: Code density refers loosely to how many microprocessor ...
28
votes
2answers
2k views

Why does 6502 indexed LDA take an extra cycle at page boundaries?

On the 6502 CPU, this instruction: LDA $0380,Y takes either 4 or 5 cycles, depending on whether the indexing crosses a page boundary. But this instruction: STA $0380,Y takes 5 cycles regardless ...
25
votes
6answers
7k views

Why are old CPUs like MOS Technology 6502 and Motorola 68000 considered better for real time systems applications than modern x86 based CPUs?

Reading the Wikipedia article about real-time computing, I found written that: Once when the MOS Technology 6502 (used in the Commodore 64 and Apple II), and later when the Motorola 68000 (used in ...
25
votes
3answers
4k views

What are uses of the byte after BRK instruction on 6502?

The BRK instruction on the MOS 6502 seems to be one of the more ill-documented features of the processor. The 1976 preliminary data sheet from MOS indicates that it's a 1-byte instruction using the &...
24
votes
4answers
11k views

Z80 x 6502 raw performance

A lot have been said in the internet about the 6502 at 1MHz being roughly equivalent in performance to the Z80 at 4 MHz. Is said that the Z80 have a typical 4 clock ticks per instruction while the ...
23
votes
1answer
1k views

How good was Woz's FP code?

I just came across this amazing 1976 article by Woz. In it he describes a relatively complete floating-point system for the 6502 with a 32-bit format (similar to earlier MS code). I understand the ...
22
votes
2answers
3k views

Why didn't the 6502 have increase/decrease opcodes for A?

In 6502 Assembly, we can use INX and INY to increase the value stored in X and Y. They can be decreased with DEX and DEY. However, it seems that there are no such instructions for A, like INA or DEA. ...
21
votes
4answers
2k views

Was the design of MS-BASIC for 6502 based on MS-BASIC for 8080?

Looking through the source code of the 6502 MS-BASIC, certain parts of it seem more reminiscent of how things would be done on the 8080, then on how they should be done on the 6502. Code to find a ...
19
votes
4answers
3k views

Why are branches relative in many 8-bit CPUs?

I was looking over an old article on the 6809 and was perusing the opcodes and noticed that the branch instructions came in two flavors, long and short. That sparked a memory about one of the 6502-...
19
votes
4answers
3k views

How did integer multiplication work in 8-bit BASIC without CPU support

I've recently been teaching my 11 year old binary multiplication, which is on the UK maths syllabus at secondary school. We have used long multiplication, eg shift and add. This has made me wonder ...
19
votes
3answers
4k views

6510 clock rate of C64: Why was it considerably slower than the 6502 of the Atari 800?

According to Wikipedia, the Atari 8 bit series had a 6502 running at ~1.8 MHz. Why was the clock speed of the 6510 for the C64, which was designed a couple of years later, considerable slower? Was the ...
19
votes
2answers
1k views

Is it possible to procedurally determine the number of cycles a particular instruction takes on a 6502?

Most emulators store the number of cycles a particular instruction takes in an array, and then adds any conditional cycles if needed (when crossing page boundaries, for example). I'm wondering if ...
18
votes
3answers
4k views

Where to buy a 6502 chip

I want to purchase a 6502 40 pin CPU in order to verify if my 6502 is faulty, I've seen I can buy from Hong Kong but would prefer closer (to the UK), RS and CPC don’t seen to have any. Most answers ...
18
votes
1answer
2k views

How did the 6502 ALU perform a decrement?

Assuming that this diagram is correct: Instructions like INC, INX, and INY can easily perform increment using ALU sum with data on B input, 0 on A input and carry_in set. But how do instructions ...
17
votes
6answers
6k views

How slow was the 6502 BASIC compared to Assembly

Imagine a modern computer, where let's say Python is a high level programming language and needs to be interpreted in order to execute a piece of code. You could write some code in C, compile it, ...
17
votes
2answers
2k views

How did the Trap65 work?

The Wikipedia page on the MOS 6502 mentions a hardware device called the Trap65 which apparently sat between the 6502 and its socket to trap any undocumented opcodes. The wiki page has the usual ...
17
votes
1answer
1k views

Why did the 6502 handle BCD with a special mode?

The 6502 had special support for BCD arithmetic, because it was widely used in those days; this much, it had in common with other CPUs. But the 8080 and 6800 implemented this in the form of a 'decimal ...
16
votes
5answers
4k views

Why are different emulators needed to run platforms that use 6502 assembly code?

To my knowledge, an emulator turns machine code for a console into something that your computer can understand. For example, assembly code from a Gamecube game is not the same as from a .exe file. ...
16
votes
2answers
5k views

What does “jmp *” mean in 6502 assembly?

Right now I am learning 6502 assembly. Currently I am using the MADS assembler to program for the Atari 800. This program is just a small tutorial program that came with the assembler zip file I ...
16
votes
3answers
4k views

How much did the 6502 and Z80 cost?

It is said that the 6502 was cheaper than the Z80. As of 1978, what were the actual prices of the two chips, in wholesale quantity?
16
votes
3answers
1k views

For how long can you safely stop the clock on an NMOS 6502?

As with most NMOS processors, the NMOS versions of the 6502 (and even earlier CMOS versions) do not have a static core. Thus, if you run the clock too slowly or stop the clock for too long while doing ...
16
votes
1answer
826 views

Why is the Apple II hi-res HGR command so slow?

The Apple II hi-res screen sits on 8KB of memory, so it should be possible to erase it quickly. The Applesoft HGR command is slow enough that the "Venetian blind" erasure is clearly visible. ...
16
votes
4answers
1k views

Best way to locate data on ROM? (6502 Processor)

Lately I've been interested in how old machines work, in particular an NES. While there are quite a few resources on the basic operations and even some games that have been totally broken down byte by ...
16
votes
2answers
2k views

6502 branch offset calculation

This question expands on How does the 6502 implement its branch instructions? I'm working on a cycle accurate VHDL implementation on an FPGA. I have much of the program logic already written, but I ...
15
votes
1answer
2k views

Why did the Apple IIe use a 2 MHz-rated 6502, even though it ran at only 1 MHz?

The Apple IIe was designed to be timing-compatible with the Apple II+ so that timing-depndent software (such games and copy-protection systems) and hardware designed for the Apple II and II+ would, ...
15
votes
3answers
739 views

Did any micros use the 6502 BCD mode in their OS?

I know the Atari's FP package used BCD for rather dubious reasons, but does anyone know of other examples of basic "operating system" level code on common platforms that used BCD? I suspect BCD was ...
15
votes
2answers
919 views

What is this code on the zero page that was put there by the BASIC ROM?

(question copied from SO (from the days before RC.SE existed): http://stackoverflow.com/q/31877835/477476) Zero-page memory maps of the PET that I've found claim that the zero page address range$00C2....
15
votes
2answers
2k views

How are 6502 and 65C02 JMP(abs) processed internally

An infamous "feature" of the 6502 is that the JMP(abs) opcode will fetch the lower byte of the jump target from the address in the instruction, and fetch the upper byte of the jump target from the ...
15
votes
3answers
514 views

What are the normal signals on a 65C02 in an Apple IIe?

I'm troubleshooting a dead Apple IIe enhanced, and I'm having trouble finding documentation on testing the 65C02 (as opposed to the 6502). Specifically, I've found using a logic probe that pin 6 (...
14
votes
12answers
4k views

Late 1970s and 6502 chip facilities for operating systems

I'm quite unfamiliar with how operating systems used to be written but its clear to me that operating systems were clearly written for these systems. I'm particularly interested in how operating ...
14
votes
7answers
1k views

New 6502 BASICs?

I sort of "have a thing for BASIC" right now, which has led to a couple of great exchanges here in RSE about the variations "back in the day". I'm wondering if anyone is aware of other modern BASICs ...
14
votes
2answers
1k views

How could high level functions with return values map to 6502 assembly? (if at all possible)

What sort of code could be used to substitute a high level function with a return value to a 6502 subroutine? Take this C-like function for example. byte func(byte a, byte b, byte c) { d = (a + b)...
13
votes
5answers
3k views

Mapping more than 64kb of address space

I'm planning out a 6502 homebrew build but seem to be stuck in the issue of buying parts. My plan is to extend the addressing capabilities of the 6502 by giving myself 64kb of RAM, and another 64kb of ...
13
votes
4answers
2k views

6502: What does the Predecode Register exactly do?

When you look at this block diagram you can see a 'Predecode Register' I suppose that the Opcode is already a 8-bit Number (D0-D7). So what was the purpose of the Predecode Register. Did it really ...
13
votes
1answer
2k views

How did the 6502 CPU get its name?

I am interested in the etymology of the name for the 6502 CPU. How were those numbers arrived at by the designers? Do they refer to anything specific? Is there some sort of origin story? I found some ...
13
votes
1answer
911 views

Does the Commodore CDTV-CR contain a 65C02 for some reason?

Browsing around the FS-UAE source code I discovered a 65(S)C02 emulation core, which appears to not be referenced anywhere outside of some CDTV-CR related source file. Apparently, a CDTV is ...
13
votes
1answer
2k views

What is the relationship between the Ricoh 2A03 and the MOS 6502?

The Ricoh 2A03 (and the 2A07) is the CPU in the well-known Nintendo Entertainment System. Apparently, the die is very similar indeed, as the slides in this video suggest https://www.youtube.com/watch?...
13
votes
2answers
678 views

BBC Master 65C102 co-processor — test memory

Out of the blue the other day, my friend found an internal 65C102 co-processor for the BBC Master in his attic, and gave it to me. It wasn't in particularly good physical condition (all the pins were ...
12
votes
0answers
527 views

Why did some MOS 6502 packages have holes in them?

Someone was recently selling an early MOS 6502 CPU on Ebay (date code 0277) in a ceramic package that had a couple of holes in it. You can see them clearly (under the tape, which presumably was not ...
11
votes
4answers
2k views

PDP-8 transistor count

https://en.wikipedia.org/wiki/Transistor_count provides some transistor count figures for early microprocessors, e.g. 8008 and 6502 both listed at around 3500. The PDP-8 was a 12-bit computer with a ...
11
votes
3answers
925 views

How does 6502 machine code process $ (address) VS #$ (value)?

How does the 6502's machine code process $ vs #$, as in it's assembly language? Does every piece of machine code have an extra byte or something telling to use addresses or values or was it something ...