Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [6502]

For questions about the 6502 series of processors, including hardware and assembly language questions. For questions about the hardware interface also use the "hardware" tag.

3
votes
2answers
231 views

How to express hi/lo byte of a label in crasm

I am trying to move my project from xa (which I found rather buggy) to crasm, which is the other 6502 assembler that comes with debian. My project contains a lot of lines like ldx #<pname ldy #&...
12
votes
4answers
3k 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. ...
7
votes
1answer
796 views

Why does this 6502 code push a function address onto the stack before calling?

I am learning how to program the Atari 800 by examining some tutorial code that came with the IDE/Assembler I am using. I am using the MADS assembler for this. putchar_ptr = $346 csrhinh = 752 ...
14
votes
2answers
4k 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 ...
2
votes
1answer
168 views

What is the format of a TurboGrafX instruction (modified 6502 instruction set)?

What is the general format of TurboGrafX processor instructions? For example, and this is made up: one word for opcode + two words for flags + one word for every parameter listed under that ...
1
vote
2answers
248 views

Resource for 6502 assembly directives?

I am currently learning about 6502 assembly. One of the documents I am learning about it from is a super mario bros. disassembly document. When I was reading the code I noticed part of the code had ...
7
votes
2answers
2k views

6502 CMP instruction doesn't compare as expected

I am trying to code in 6502 assembly and for some reason the CMP instruction doesn't work. For example: CLD LDY #$03 LDA #$00 LDX #$05 CMP Y BEQ Equal STX $0200 Equal: BRK ...
1
vote
2answers
221 views

Acorn System 1 - is it a collectable? [closed]

I have one of these things gathering dust at home: Acorn System 1 I have the original manual (when I find it?) too. It did work, the last time I powered it up, 35 years ago. Should I throw it in ...
6
votes
2answers
401 views

Hardware multipliers on classic CPUs

Can anyone offer some back-of-envelope sort of estimates of what sort of gate count was needed to add a multiplier to 8-bit CPUs? I ask because I find it a bit odd that the 6809 had one, but none of ...
15
votes
2answers
1k 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 ...
6
votes
1answer
177 views

DEX: How does a 2-Cycle instruction affect RCL outputs AFTER it completes?

I (as so many people before me) am developing a software simulation of the 6502, mostly based on the often cited block diagrams and several other sources of information. Basically all the components ...
4
votes
1answer
405 views

Fastest way to write 0x00 to a zero-page memory location? (6502, Atari 2600)

I have a kernel in my 6502 game that writes two dots to a sprite, so for example: ........ ........ .XX..XX. .XX..XX. ........ ........ Either 0, 1, or 2 dots can be on at a time. This is done one ...
3
votes
2answers
1k views

Why do they use CLI in an IRQ routine?

I am studying an FLI routine in http://codebase64.org/doku.php?id=base:fli_displayer and I noticed that the CLI instruction is being used in this IRQ routine: irq0: pha ... cli ; &...
2
votes
3answers
672 views

How can a Z80/8080/6502 use VGA?

I've come across a couple of projects that manage to get VGA working with the Z80 and similar CPUs: Veronica (6502 CPU, VGA signal generation by AVR) ZC160 (Z80 CPU, VGA signal generation by GAL) c-...
5
votes
5answers
773 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 ...
1
vote
2answers
345 views

Reading both keyboard and joystick with non-KERNAL code on C64

I'm implementing non-KERNAL joystick and keyboard controls for my Commodore 64 game. I used to use the KERNAL SCNKEY routine earlier to read keyboard and it worked well with my joystick port 2 code. ...
6
votes
3answers
592 views

Was there any particular reason the 6502's LDX#imm and LDY#imm aren't opcodes A8 and AA?

Parts of the 6502 opcode map are fairly regular, and parts of it aren't. One bit that strikes me as really weird is the decoding of LD_ instructions, in relation to the decoding of other ALU ...
9
votes
2answers
276 views

Can 6502 programs be transliterated to the SPC700?

The SPC700's instruction set is derived from the 6502's, but moves the instructions around and adds a few. But is it fully backwards compatible? Assuming that the program fully separates data and ...
8
votes
3answers
607 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 ...
9
votes
3answers
2k 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 ...
4
votes
0answers
115 views

How does the 6502 check the negative flag internally? [duplicate]

I am currently developing a subset of the 6502 in LogiSim. One of my main resources is Hanson's Block Diagram. Currently I am developing opcodes for the processor, and my current task is the ...
6
votes
2answers
418 views

Is there a place where I can find 6502 instruction lines by opcode?

I am currently designing a watered-down version of the 6502 in Logisim. I am working off of Hanson's Block Diagram to build my subset. I have fully built the processor using the diagram and other ...
6
votes
2answers
390 views

Unsigned addition on the 6502

I am currently playing around with pointer and indirect addressing on the C64 and I encountered a problem with the ADC opcode. I am trying to increment a number repeatedly and when it overflows (goes ...
9
votes
1answer
511 views

Why are some soft switches on the Apple II only triggered with a write?

The Apple II uses memory mapped I/O and soft switches to do many things. One thing has confused me though: why are some soft switches only activated when written to? For example, 80COLON ($C00D) and ...
17
votes
3answers
754 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 ...
10
votes
5answers
1k 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 ...
12
votes
4answers
765 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 ...
3
votes
1answer
196 views

Which material was used for the 6502/6510/8500 MOSFETs?

I know that in the 80s, there was a shift from aluminum gate material to polycrystalline silicon. I wonder because the 6502 was released in 1975 and there were a lot of different implementations and ...
22
votes
1answer
2k 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 ...
9
votes
2answers
359 views

Is the software available to simulate building a computer from the ground up? For example a system based on the 6502 [closed]

I recently got me head round the basics of how a CPU works after watching Ben Eaters 8bit bread board computer series of internet videos. Now I am hooked and i want to take my understanding further. ...
19
votes
3answers
2k 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 ...
15
votes
3answers
2k 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 ...
13
votes
2answers
538 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 ...
14
votes
3answers
2k 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
2answers
1k 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 ...
13
votes
1answer
921 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
816 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)...
11
votes
3answers
581 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 ...
12
votes
1answer
388 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 ...
18
votes
2answers
982 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 ...
78
votes
7answers
25k 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 ...
29
votes
2answers
4k 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 ...
15
votes
3answers
366 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 (...
13
votes
2answers
743 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 ...
-6
votes
2answers
532 views

Which computers / consoles used the 6502 and 65816 chipsets? [closed]

The Apple II and Commodore 64 are the obvious ones but which other computer systems used the 6502 and 65816 chips?
14
votes
1answer
545 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. ...
23
votes
2answers
912 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 ...
14
votes
2answers
661 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....