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
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 ...
47 votes
3 answers
6k 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 ...
4 votes
3 answers
193 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 ...
24 votes
4 answers
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 than on how they should be done on the 6502. Code to find a ...
1 vote
1 answer
208 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 ...
42 votes
5 answers
7k 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 ...
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 ...
12 votes
1 answer
2k 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 ...
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 ...
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 ...
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 ...
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 ...
12 votes
1 answer
796 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'...
1 vote
1 answer
234 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 ...
31 votes
3 answers
7k views

Why didn't the 6502 have increment/decrement 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. ...
16 votes
4 answers
3k 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 ...
18 votes
2 answers
3k views

Why does the 6502 JSR instruction only increment the return address by 2 bytes?

Currently messing with 6502 assembly on a C64, and I don't understand why the JSR instruction is so weird. According to the instruction table, JSR is a 3-byte instruction and only operates in absolute ...
13 votes
1 answer
530 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 ...
47 votes
6 answers
12k 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 ...
3 votes
1 answer
216 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 ...
4 votes
0 answers
233 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 ...
7 votes
2 answers
3k 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 ...
55 votes
13 answers
10k 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 leveraged to be an abstraction of a CPU for porting Unix) was not a very easy language to ...
4 votes
1 answer
560 views

Clear description of MS BASIC number → string conversions?

I'm failing to find a concise document that describes the formatting used by (6502) MS BASIC when converting internal floating-point numbers to text for display in PRINT, STR$, etc. I know it has a ...
7 votes
1 answer
305 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, ...
0 votes
4 answers
565 views

How did graphics processing for old 8/16bit consoles work & what are the differences between an FPU/maths co processor & a graphics card? [closed]

When looking at information on the Internet about old consoles it's rather easy to find information on CPUs like the 6502, 65816, 68000 & Z80 used in retro computers & consoles like the NES, ...
22 votes
7 answers
5k views

Why were there no 32-bit versions of 65xx CPUs, or 64-bit versions of m68k CPUs?

I don't understand why Western Design Center made the 65816 a 16-bit upgrade to the 6502 but Commodore Semiconductor Group/MOS Technology didn't make their own variant & why neither company made ...
20 votes
3 answers
7k 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?
6 votes
2 answers
259 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....
3 votes
1 answer
195 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 ...
9 votes
4 answers
2k views

How is PETSCII used by assembly-language programs?

First, a bit of context. I wrote an interactive disassembler for 6502 code that, among other things, attempts to identify ASCII strings automatically. Appropriate source code for different assemblers ...
4 votes
2 answers
886 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
4 answers
2k views

Why did decimal arithmetic slow down VisiCalc?

There is an excellent article about VisiCalc that goes into all the details about what happened and why, highly recommended if you are interested in that part of computing history. I was reading this ...
10 votes
1 answer
362 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: ...
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 ...
11 votes
4 answers
1k views

Did the 6502 need both ADC immediate and SBC immediate?

The 6502 uses the carry bit system (over a borrow bit). On such machines, the bitwise NOT is applied to the subtrahend before it is "subtracted" (really, added, taking advantage of two's complement) ...
2 votes
3 answers
971 views

Efficiently defining a C function by given address in cc65

I have a function that should be callable with the following syntax: void __fastcall__ initSIDplayer1(uint8_t a); The __fastcall__ modifier here means that the argument is passed in the Accu instead ...
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 ...
15 votes
3 answers
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 ...
39 votes
7 answers
26k views

Comparing raw performance of the Z80 and the 6502

A lot has been said on the internet about the 6502, at 1MHz, being roughly equivalent in performance to the Z80, at 4 MHz. It is said the Z80 has a typical 4 clock ticks per instruction, while the ...
2 votes
2 answers
349 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 ...
12 votes
1 answer
980 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 ...
8 votes
4 answers
836 views

Could the 6502 have worked with an Altair-style front panel?

I have fond memories of programming the 6502, though I never did any hardware hacking with it. I notice that the Altair, with its iconic front panel, was based on the Intel 8080, and from then on, ...
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 ...
10 votes
1 answer
1k views

6502 double store and copy protection?

I was watching a video on netlist simulation of the 6502. The presenter mentions how the 6502 has a double store upon using INCY, and then offhandedly mentions that this can be used for copy ...
2 votes
2 answers
371 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 ...
16 votes
1 answer
1k 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 ...
2 votes
1 answer
365 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 ...
9 votes
1 answer
513 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 ...
8 votes
1 answer
693 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 ...