Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
8 votes
2 answers
2k views

Why does the BRK instruction set the B flag?

On the 6502, the brk instruction is a software interrupt. Like any other interrupt, it pushes the status word to the stack and then the program counter, before transferring control to an interrupt ...
Omar and Lorraine's user avatar
9 votes
2 answers
499 views

What elements of the MOS 6502 did it copy from the Motorola 6800?

It is not uncommon for microprocessor system designers to copy elements of design from other microprocessor systems; the Z80, extensively copying design elements of the 8080, is a notable example. ...
cjs's user avatar
  • 26.6k
2 votes
1 answer
225 views

What was the 6502's reset behaviour when the RDY pin was low

How does an original 6502 behave if the ready pin is being held during a reset/power-on event? Would it pause CPU start-up entirely, delaying when some or all of the 6 internal cycles are executed? (...
David's user avatar
  • 2,346
15 votes
2 answers
1k views

Why is the addressing mode for BRK defined as "stack" in the W65C02S datasheet?

I most online documentation, I find the addressing mode for BRK to be "implied", which is logical. In the W65C02S datasheet however, it is set as "stack": Is there some reasoning ...
Bart Friederichs's user avatar
4 votes
1 answer
426 views

Is there an standardised 6502 assembly syntax?

I am working on a Flex/Bison based 6502 assembler (for fun and learning) and looking around for a "standard" syntax for the assembly language. Opcodes and addressing are more or less ...
Bart Friederichs's user avatar
4 votes
3 answers
210 views

ProDOS BASIC.SYSTEM overwrites RNDL ($4E) - how to get random numbers

I am writing an application that uses random numbers. The plan is to use RNDL/RNDH ($4E) to initialize a pseudo-random number generator. Unfortunately, I keep getting the same sequence. Tonight, I ...
A2Geek's user avatar
  • 103
13 votes
11 answers
5k views

Did any 8-bit device ever merge a CPU core?

Looking at https://upload.wikimedia.org/wikipedia/commons/c/c1/Commodore-64-1541-Floppy-Drive-04.jpg I started thinking the following: There are too many chips in that drive. It is crying out for a ...
rwallace's user avatar
  • 61.4k
1 vote
1 answer
219 views

Synchronising FOR - NEXT routines in C64 basic [closed]

I am writing a program which has an ASCII background, animating character moving to random locations, and finally adding music It's my first ever C64 attempt and I want to finish it in BASIC before ...
Journeyman1234's user avatar
8 votes
2 answers
1k views

Help understanding TAIPAN source code for the Apple II

I am trying to run the source code found at https://taipangame.com/BASIC.txt on Epple 2 (with Apple II+ roms) to eventually run on my own Apple II+, but the program keeps crashing. First, I used a ...
EvanTheGamer's user avatar
8 votes
1 answer
1k views

C64 char screen plot routine - not clear about reason for logical OR

I'm trying out some 6502 assembly language, specifically using Kick Assembler. I have the following routine that just sticks a character on the text screen at a specified x and y, it's taken from the ...
Alan B's user avatar
  • 4,620
13 votes
3 answers
2k views

What's the convention for < > low/high-byte in 8-bit assembler?

It's a little hard to Google for greater-than and less-than symbols in assembler math... If you saw, let's say, 6502 code like... lda #>SOME_LABEL or Z80 code like... ld a,>SOME_LABEL ...would ...
Luxocrates's user avatar
12 votes
1 answer
834 views

Were there 6502 revisions B and C, and what were they like?

The first 6502 was the 6502 revision A, which famously does not include the ROR instruction (this is sometimes described as a hardware bug, but that's apparently a myth). Then, some time later, there'...
Omar and Lorraine's user avatar
1 vote
1 answer
265 views

Interfacing with the Commodore 64 IEC Serial Port using Assembly

I'm struggling a bit to find relevant documentation on this subject when it comes to using just assembly. All I've found is either irrelevant or for BASIC. My goal is to be able to send and receive ...
SkyeG06's user avatar
  • 21
13 votes
1 answer
561 views

Error in Apple I manual's Wozmon listing or Hardware description?

The Apple I Operation Manual includes a full listing of Steve Wozniak's amazing 256 byte 6502 Hex Monitor, aka Wozmon, as well as some explanation of how to interact with the Apple I hardware. My ...
Jason Clark's user avatar
3 votes
1 answer
222 views

45GS02 (65CE02) stack high register

I was looking through some source for a 6502 cross-assembler and noticed that the extensions for the 45GS02/65CE02 (C65) have an oddity - while most of the new registers are set through the acc using ...
Maury Markowitz's user avatar
7 votes
1 answer
321 views

Is there really any implementation of a Ada compiler/cross-compiler/interpreter for 6502?

I found some Ada compilers for CP/M machines but no luck for 6502-based C64/Apple II/BBC Micro. I'm not sure if Abacus Ada on C64 exists or how much a subset it implements for Ada. There is, though, ...
Schezuk's user avatar
  • 3,754
27 votes
7 answers
7k views

Did anyone ever run out of stack space on the 6502?

Unlike its main rival the Z80, the 6502 had a size limit of 256 bytes for the hardware stack. That sounds like a very tight limit, but in my experience, it was never actually an issue; by the time you ...
rwallace's user avatar
  • 61.4k
6 votes
2 answers
285 views

6502 Assembly on Apple IIe: GETLN fails with 'syntax error' under ProDOS

I'm writing a text adventure in assembly for the Apple IIe (using Merlin). I'm also using ProDOS 8 v2.0.3. At some point, I have a subroutine to read user input from the keyboard using the GETLN1 call....
Taciano Dreckmann Perez's user avatar
3 votes
1 answer
212 views

How can I check whether a define-style string macro is defined in CA65?

I have spent hours trying to figure out how to get conditional include paths functional in CA65 (or really, any conditional string values at all). Is it even possible? What I want is to be able to ...
Mara Ormston's user avatar
10 votes
1 answer
366 views

Why would a Reset key bounce disconnect Apple DOS?

This answer stated that hitting the Apple II Reset key twice, in quick succession, could cause DOS to be disconnected from the I/O hooks. I don't understand why that would happen. Quick background: ...
fadden's user avatar
  • 9,050
12 votes
3 answers
3k views

Why doesn't the NMOS 6502 have the illegal instruction, STA immediate?

The 6502's instructions have the form aaa-bbb-cc, where cc picks an instruction group. Group 01 is the most regular and easy to understand. In this group, aaa picks an instruction from the list 000 ...
Omar and Lorraine's user avatar
8 votes
2 answers
2k views

Which order does the 6502 read its vectors in?

I'm looking at gianlucag/mos6502 and Mike Chambers' fake6502. They have observable differences in the way that they read the reset vector. Rubbermallet reads the $fffc first, and then $fffd. I'm ...
Omar and Lorraine's user avatar
12 votes
1 answer
1k views

Carry handling during address generation on a 6502

I'm trying to learn a bit more about the internal workings of the 6502. The manual says that the branch instructions do not affect the carry flag. However, my understanding is that some carry handling ...
Patrick LeBoutillier's user avatar
17 votes
1 answer
3k views

Why was the 6502 version of Microsoft BASIC coded like the 8080 and 6800 versions even though this was rather inefficient?

It's quite clear that the 6502 version of Microsoft BASIC at all levels uses substantially the same structure and technique as the earlier 8080 and 6800 versions. As has been pointed out in various ...
cjs's user avatar
  • 26.6k
2 votes
2 answers
377 views

From an electrical and software engineering perspective, ignoring available software, should I go for the Z80 or 65C02? [closed]

This might be a weird title but I noticed that recommendations for one over the other usually go into a direction that is not too helpful for me. I would like to build an 8 bit computer and picked ...
Asyx's user avatar
  • 29
2 votes
1 answer
374 views

Obtaining a CPU execution trace on a Commodore 64 [closed]

I need to collect the execution trace of all instructions executed by the 6502 on a C64. I tried C64 Debugger, but I couldn't find any option for this. Is it possible to obtain with C64 Debugger? Are ...
Digerkam's user avatar
  • 301
9 votes
1 answer
521 views

What is the purpose of the 2x4-bit split of the PCH incrementer?

On this detailed 6502 block diagram that can be found all over the net, the increment logic for the high byte of the program counter is split into two 4-bit parts, with a named PCHC line for the carry ...
Cactus's user avatar
  • 2,708
8 votes
1 answer
780 views

How does the VIC-II/CPU memory access work on the C64?

As a programmer I knew that on the C64 the CPU got the bus in the high phase of PHI2 and the VIC-II got it in the low phase and also stole extra high phases when required. However, it wasn't until ...
Robin Elvin's user avatar
6 votes
0 answers
698 views

Transistor-level schematic of 65C02

I am looking for a transistor-level schematic for the 65C02, something like the one for the 6502 created by davidmjc (https://github.com/davidmjc/6502). I am a teacher planning to give a student ...
JRN's user avatar
  • 1,265
1 vote
1 answer
274 views

Transfer between bus and register in 6502 CPU

For one register of 6502 CPU (here X Index register) : If the SB/X (load) signal and X/SB (bus enable) signal are both asserted at the same time, what happens ? X Index register take the bus value ...
Johnmph's user avatar
  • 389
2 votes
1 answer
281 views

Timer B Interrupt occurs only once

I was following this tutorial on Commodore 64 timer interrupts and tried to replicate it (except all I was planning on doing was changing the border color.) I noticed that my interrupt only occurs ...
puppydrum64's user avatar
  • 1,638
3 votes
1 answer
308 views

Did any 6502-based system with cycle-stealing memory access steal the first available read, rather than asserting READY three cycles early?

On the 6502, the READY signal may be used to extend read cycles indefinitely, but will have no effect if asserted during write cycles. As a result, many devices that need to steal cycles from the CPU ...
supercat's user avatar
  • 36.5k
14 votes
3 answers
3k views

When was the 6502 second sourced?

According to https://en.wikipedia.org/wiki/Second_source MOS Technology licensed Rockwell and Synertek to second-source the 6502 microprocessor and its support components. This makes sense; the 6502 ...
rwallace's user avatar
  • 61.4k
10 votes
2 answers
2k views

How did the 6502 designers intend for the indirect addressing modes to be used?

The 6502 has three indirect addressing modes: Indirect, Indexed Indirect (Indirect,X) and Indirect Indexed (Indirect,Y). Indirect is only used on the JMP instruction, no other. Why was this mode ...
nexus_2006's user avatar
  • 1,065
16 votes
3 answers
3k views

Can the 6502 clock be changed on the fly?

I was wondering if the original NMOS 6502 has any timing limitations on changing the clock rate during operation? I ask, because the CSG 8502 version could "run at double the clock rate of the ...
Maury Markowitz's user avatar
12 votes
1 answer
813 views

How common was MADSEL?

I recently completed a software disassembly of the 1980 coin-op arcade game Missile Command. I'm curious whether a feature of the hardware is unique or commonplace. First, a bit of background: ...
fadden's user avatar
  • 9,050
13 votes
6 answers
2k views

Could the Z80 do interference-free video as the 6502 could?

Technically this isn't just about video since it applies to any regularly scheduled DMA¹ from a non-CPU subsystem, but video is the most common application of this technique so I'll use that as the ...
cjs's user avatar
  • 26.6k
6 votes
1 answer
248 views

What bit do the BBRn/BBSn opcodes check?

I am working with a W65C02S chip and it has extra opcodes, BBRn and BBSn that branch on a bit set, or bit reset. However, I cannot find on which register or memory location this check is done. When ...
Bart Friederichs's user avatar
3 votes
1 answer
206 views

CC65 ignores request to correctly offset memory areas in output files

I'm trying to segment my C code into two distinct memory areas, one which will be flashed to a ROM chip and another which will end up somewhere else. Here is what I have in sbc.cfg (I was originally ...
ifconfig's user avatar
  • 133
9 votes
0 answers
243 views

Systems that used the Rockwell R65C00/21 or R65C29

The Rockwell R65C00/21 and R65C29 are described in an October 1984 datasheet ("R65C00/21 dual CMOS microcomputer and R65C29 dual CMOS microprocessor," Document no. 29651N64, rev. 2) which is ...
JRN's user avatar
  • 1,265
5 votes
1 answer
377 views

Apple II Assembly DSECT

I'm trying to define a section of data in a program. The Apple 6502 Assembler/Editor mentions an assembler directive called "DSECT" but I can't tell if I'm using it correctly or not. Here is ...
Kuang's user avatar
  • 53
25 votes
2 answers
4k views

Was leaving all xxxxxx11 opcodes unused on the 6502 a deliberate design choice?

The 6502, like many 8-bit processors, has a somewhat arcane opcode-mode restrictions. On most such processors, the restriction is a clear result of trying to pack a lot of instructions into a limited ...
supercat's user avatar
  • 36.5k
2 votes
2 answers
352 views

How to properly convert an active-low joystick routine to active-high

My last question wasn't specific enough so I'll rephrase it. I've been having trouble with programming game consoles/computers like Commodore 64 that have active-low joysticks, where the bits are all ...
puppydrum64's user avatar
  • 1,638
19 votes
3 answers
5k views

What is the purpose of mirrored memory regions in NES's CPU memory map? [duplicate]

[Please see answers to this related question as well] I've started reading the "official" NES Documentation and in page ten, it says that "memory locations $0000-$07FF are mirrored ...
anmomu92's user avatar
  • 193
6 votes
1 answer
283 views

Commodore 64 sound seems to freeze at a high pitch if executed too soon after startup

I created this little sound driver for sound effects, it makes a classic "laser beam" sound you would hear in old arcade games. There's just one problem, and it's a bit of a strange one. I ...
puppydrum64's user avatar
  • 1,638
3 votes
1 answer
155 views

Spontaneous movement and game crashes from active-low joystick routines [closed]

I've noticed this recurring problem when I'm trying to program joysticks or buttons that are active-low (0 = pressed), like on the Commodore 64 or Game Boy Advance. Regardless of the language or ...
puppydrum64's user avatar
  • 1,638
4 votes
2 answers
945 views

How to wait for vBlank on Commodore 64

I'm not new to 6502 Assembly but I am new to the Commodore 64. I'm used to the NES where you have to write everything yourself, such as the NMI/RESET/IRQ vectors, etc, but from what I understand the ...
puppydrum64's user avatar
  • 1,638
6 votes
2 answers
487 views

Macro for counted string accepting multiple arguments?

Using ca65 assembler, I'd like to use a macro to encode a string as a pascal style string or FORTH counted string with a leading length byte. In ca65 documentation there is this example: ....
Alexandre Dumont's user avatar
11 votes
3 answers
2k views

Protecting 6502 decimal mode code from interrupts

A common idiom in 6502 assembly code is to protect sequences of code that rely on decimal mode from being interrupted. This because an interrupt handler typically clears decimal mode (cld), and thus ...
Brian H's user avatar
  • 60.8k
11 votes
3 answers
3k views

C++ compilation for the Z80 and 6502?

I know it's almost heresy to ask something like this, but ... We have C compilers for the Z80/6502 and there used to exist a thing called the Comeau C++ compiler, that produced C code as output. There ...
user1095108's user avatar