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
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 ...
8
votes
1answer
313 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 ...
2
votes
1answer
264 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 ...
8
votes
1answer
786 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 ...
8
votes
1answer
283 views

Why does the 6502 read from the stack before writing it?

I am building a W65C02S based computer for fun, and I try to build basically all the tools myself. Including the assembler (yes, I know they exist, I just want to make everything from scratch myself, ...
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 ...
6
votes
3answers
1k views

What is the MOS 6502 doing on each cycle of an instruction?

So, first off, I am kind of a noob with emulators and the 6502. Summarise the problem If we for example take the instruction ADC Immediate ($69) which adds the accumulator to an immediate value and ...
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. ...
10
votes
5answers
3k views

Why were there no 32-bit or 64-bit versions of the m68k & 65xx lines of 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 ...
4
votes
2answers
437 views

How much memory does this SYM-1 have?

I have a SYM-1 with the following memory configuration: How much memory is that? Those all appear to be L2114UCE chips, which are described as "Static 1024x4 NMOS RAM", but I'm not sure how ...
4
votes
1answer
530 views

Sym-1: What is the “f” register?

Running SUPERMON on a Synertek SYM-1, the R (REG) command cycles through a number of registers. Most are self explanatory: p is the program counter (pc) s is the stack pointer a, x, and y are obvious ...
6
votes
4answers
1k views

Efficient way to JMP or JSR to an address stored somewhere else?

I'd like to JSR or JMP (preferably JMP as it's 3 cycles cheaper) to an address stored somewhere else in memory, the address of which is itself indexed. I came up with the following self-modifying code ...
6
votes
1answer
146 views

Chaining IRQ's with BASIC & Kernal routines turned off

Having disabled BASIC and Kernal routines I set up an IRQ to run the following code when the raster line reaches 200: .irq1 inc 53280 // change border colour // lda #$ff // clear the ...
0
votes
1answer
136 views

Defining a C function with 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 ...
4
votes
2answers
400 views

The use of segments in non-relocating assemblers

I've been looking at a bunch of different 6502 assemblers recently (dasm, ca65, xa, kickass), and many of them have support for multiple code segments. Some of these assemblers can generate ...
0
votes
3answers
309 views

How was “Super Mario Bros” made with Assembly if the DASM compiler came out in 1987?

Would somebody care to explain how "Super Mario Bros." was released in 1985. But the DASM Assembler came out in 1987? The 6502 Assembly language was introduced in 1975. How would you compile/...
2
votes
1answer
84 views

Defining zeropage address labels in xa assembler?

I am trying to use the xa assembler to write some 6502 code. According to the documentation, I can define a zeropage segment using the .zero pseudo-op. I was hoping to do something like this: .zero ...
11
votes
1answer
1k views

Identifying this 6502 Assembler

I found some 6502 assembler code for a Commodore 64 program that uses meta commands like #include "foobar", define the address to be assembled to via *=$1234 and define labels without a colon. ...
4
votes
1answer
206 views

Basic / Assembler startup code (C64)

I'm just creating my own .prg file using NCurses Hexeditor in Ubuntu which I load using load"file.prg",8 in Vice. I followed the information in this link explaining how to create a .prg file....
10
votes
4answers
487 views

Commodore BASIC: why was the PET's GOTO so slow?

Received wisdom has it that Commodore didn't want to pay Microsoft extra for updated BASIC interpreters, and thus very little changed in Commodore BASIC v2 from the PETs to the C64. But consider the ...
9
votes
4answers
1k views

Modulus arithmetic on the 6502

I have a very simple problem with is turning out to be surprisingly complex to solve. I wish to add two bytes using modulus arithmetic, where the modulus is known at compile time. e.g. given modulus 5,...
7
votes
1answer
258 views

Is there a possibility for a user-defined IRQ hardware vector on a Commodore 128 in C128 mode?

When an IRQ occurs, the 6502 microprocessor and its derivatives in the C64 and C128 push the status register to the stack and then load the contents of a two-byte vector at memory address $FFFE/$FFFF ...
6
votes
2answers
413 views

Labels in cc65 inline assembler with #define macro

In general, it is possible to use inline assembler statements within C macros, for example #define toscreencode(C) (__AX__ = (C), \ asm("cmp #$60"),\ ...
9
votes
3answers
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 ...
3
votes
2answers
241 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
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 ...
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 ...
6
votes
1answer
506 views

Putting code into two different memory areas with cc65/ca65

According to cc65 / ca65 documentation, the .org directive does not affect the placement of the code unlike with other 6502 assemblers. The docs suggest defining a memory segment with the intended ...
0
votes
4answers
192 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 on the internet at information about old consoles it's pretty easy to find out information on CPUs like the 6502, 65816, 68000 & Z80 used in retro computers & consoles like the ...
3
votes
2answers
394 views

How were games and programs written for the C64 in assembler in the 80s? [duplicate]

Were developers using monitors like e.g. "Supermon+64", "Merlin 64" or "Monitor$C000" and cartridges like "Final Cartridge", "Action Replay" (both of ...
3
votes
1answer
275 views

When did the faster versions of the NMOS 6502 become commercially available?

The 6502 was released in 1975 with an advertised speed of about 1mhz but I can't find reliable information on what year faster versions became available (was 2mhz possible at launch?) or what the true ...
11
votes
3answers
2k views

Behavior of the zero and negative/sign flags on classic instruction sets

It seems to me that there's effectively two ways that the zero bit could work. Z is set iff the result of a computation is mathematically equal to 0. Z is set iff a bit pattern consisting entirely of ...
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 ...
2
votes
1answer
254 views

Does the 6502's TXS and TSX affect flags or not?

Title says it all really. Some documentation claims that the S and Z flags are affected by both TXS and TSX, just as with all other transfer commands. Other documentation suggests that neither TXS nor ...
3
votes
2answers
486 views

Why don't all Absolute,X instructions take an extra cycle to cross page boundaries?

The question is about 6502 instructions that take an extra cycle when address calculation carries over into the high byte of the address. This affects addressing modes Absolute,X, Absolute,Y, Indirect,...
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 ...
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 ...
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 ...
7
votes
4answers
4k 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-...
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 ...
5
votes
4answers
903 views

6502: is BCD *fundamentally* the same performance as non-BCD?

Furthering my reading of MS BASIC and Woz's FP code and comparing the two leads to another question specific to the 6502... From what I can see looking over the 6502 instruction guides, it appears ...
8
votes
3answers
510 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) ...
4
votes
4answers
406 views

Would having the console's CPU help in emulation hypothetically?

If I had a hypothetical computer just like nowaday's computers, but it had an NMOS 6502, would it provide me with a better emulation experience than if I were to emulate the 6502 inside software? Also,...
1
vote
6answers
2k views

Compile the 6502 assembler source code for running on modern computers [closed]

I want to make an executable file for modern computers that you can download and run without any other software, using any kind of a 6502 assembler. Can I compile source code, written for the 6502, ...
11
votes
3answers
418 views

Do any 6502 assemblers have better support for self-modifying code?

I find I keep on doing things like this: raster_interrupt: bgnd_color = * + 1 lda #$00 sta $d021 ; rest of interrupt handler so that I can do this kind of thing elsewhere in my ...
9
votes
1answer
283 views

6502 False Reads and Apple II I/O

The 6502 series of CPUs has an interesting quirk: indexed loads and stores may perform a "false read", reading from the target address or a different address on a previous page. There are situations, ...
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 ...
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 ...
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 (...
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 ...