Questions tagged [6502]

The 6502, developed by MOS Technology, is an 8-bit microprocessor that was in common use as a microcomputer and video-game CPU from the late 1970s through to the early 1990s, notably powering products from Commodore, Apple, Atari, Acorn and Nintendo.

The 6502, developed by MOS Technology (later CSG, Commodore Semiconductor Group) and subsequently licensed to Rockwell and Synertek, is an 8-bit microprocessor with a 16-bit address bus that was in common use as a microcomputer CPU from the late 1970s through to the early 1990s. Typical clock speed implementations drove the CPU at either 1MHz or 2MHz, though the device was not locked to these speeds and could be over/under-clocked to a degree.

Commodore, Apple, Atari, Acorn and Nintendo notably featured the device in numerous microcomputers and video-game consoles during that time. Variant models include the 6507 and 6510, whilst later revisions include the 65C02 and 65C816. These models either lacked some functionality (6507) or enhanced the original design.

231 questions
27
votes
7 answers

CPU Emulation and locking to a specific clock speed

If you had read my other question, you'll know I've spent this weekend putting together a 6502 CPU emulator as a programming exercise. The CPU emulator is mostly complete, and seems to be fairly accurate from my limited testing, however it is…
FlySwat
  • 172,459
  • 74
  • 246
  • 311
21
votes
7 answers

6502 CPU Emulation

It's the weekend, so I relax from spending all week programming by writing a hobby project. I wrote the framework of a MOS 6502 CPU emulator yesterday, the registers, stack, memory and all the opcodes are implemented. (Link to source below) I can…
FlySwat
  • 172,459
  • 74
  • 246
  • 311
14
votes
3 answers

Fast signed 16-bit divide by 7 for 6502

I am working on an assembly language program for a 6502 cpu, and am finding that I need a fast-as-possible divide-by-seven routine, in particular one which could take a 16-bit dividend. I am familiar with the routines found here, but generalizing…
markt1964
  • 2,638
  • 2
  • 22
  • 54
12
votes
3 answers

Interested in VM for lisp-like languages on 8-bit system

I'm looking for recommended virtual machines that can run on a 8-bit microprocessor AND support dynamic languages. I'd like a VM solution because I perceive benefits in terms of code density, portability, and ability to have a smaller interpreter,…
12
votes
3 answers

6502 Emulation Proper Way to Implement ADC and SBC

I've been working on an emulator for the MOS 6502, but I just can't seem to get ADC and SBC working right. I'm testing my emulator with the AllSuiteA program loaded at 0x4000 in emulated memory, and for test09, my current ADC and SBC…
NAME__
  • 625
  • 1
  • 7
  • 17
12
votes
6 answers

Seeing how Instructions get Translated (Computer Architecture)

Little bit of a confusing question. But Im really looking for learning some low level programming. Thing is, Dev boards like Arduino/Etc. really hide alot of whats going on. I have spent some time learning about Computer Architecture,…
user475353
11
votes
2 answers

Waiting for a change on $D012 (C64 assembler)

I've run into a few issues while playing around with asm on an emulated C64 machine. What I want to do is to check if the key "N" on the keyboard is being pressed, then the program should wait for a change to appear on address $D012. Now what I…
user1062704
  • 438
  • 4
  • 14
11
votes
1 answer

6502 lightweight compression algorithms

I'm implementing virtual memory on dual cassette tape decks on a Commodore PET (for fun) for a Forth I'm writing. What I have so far is at http://github.com/chitselb/pettil if you're interested. I'm planning to use the PET's native 192-byte…
chitselb
  • 153
  • 5
10
votes
3 answers

How to define VALUE and TO

I want to implement the Forth words VALUE and TO on a RPC/8 (an emulated computer in a Minecraft mod). My best attempts get me a set of words that work fine so long as I don't use them while compiling. More sepecificly VALUE works, but TO does…
Milo Christiansen
  • 3,204
  • 2
  • 23
  • 36
9
votes
2 answers

C64 Assembly Rendering a Sprite

I have written a short program in 6502 assembler for the Commodore 64 using the ca65 assembler and ld65 linker. The program should render a solid square sprite somewhere near the center of the display, but I don't see anything being rendered. This…
Woodrow Barlow
  • 8,477
  • 3
  • 48
  • 86
9
votes
4 answers

Writing a while loop in assembly

I'm trying to write a while loop in assembly with a 6502 processor and I cannot figure out how to write the hexadecimal code. I've seen examples written using the shorthand where there is a label for where the loop should begin and end but I do not…
jnhyf
  • 91
  • 1
  • 1
  • 3
9
votes
2 answers

How to change kernal SCNKEY routine behaviour in Commodore 64

I'm trying to implement game controls using kernel routines in Commodore 64. Below code works with one exception. Each key stroke counted as single input. e.g.: There is no effect if you keep holding the button. You had to release and press again…
wizofwor
  • 917
  • 8
  • 25
9
votes
1 answer

Interrupt behavior of a 6502 in standalone test vs. in a Commodore PET

I am building a Commodore PET on an FPGA. I've implemented my own 6502 core in Kansas Lava (code is available at https://github.com/gergoerdi/mos6502-kansas-lava), and by putting enough IO around it…
Cactus
  • 27,075
  • 9
  • 69
  • 149
9
votes
2 answers

Can I turn this into a loop through some 16-Bit Magic?

I'm starting out with 6502 Assembly right now and have a problem wrapping my head around loops that need to deal with numbers bigger than 8 bit. Specifically, I want to loop through some memory locations. In pseudo-c-code, I want to do this: //…
Michael Stum
  • 177,530
  • 117
  • 400
  • 535
8
votes
8 answers

Getting random number from 6502 assembler

Trying to generate a series of random numbers on my Commodore 64 (C64) using JSR $E09A and retrieving the number from $63 and $64. (which according to all the documentation I've seen is the same routine when you use RND(0) from BASIC. But can't get…
Kenny
  • 171
  • 1
  • 6
1
2 3
15 16