Jump to content
NHL'94 Forums

Neat story about the 6502 CPU (NES.. sorta SNES..)


smozoma
 Share

Recommended Posts

The 6502 was the CPU chip in the NES, and the SNES CPU was an upgraded version of the 6502.

The chip was designed by hand by Bill Mensch and worked the first time, which is unheard of, since it usually took about 10 revisions to get a CPU to work in those days. It had 3510 transistors arranged to do all the adding, subtracting, multiplying, storing, loading, etc., of data.

link: The MOS 6502 and the Best Layout Guy in the World

Here you can watch the 6502 working. Press z to zoom in, x zoom out, and n to advance the time in the simulation.

http://www.visual6502.org/JSSim/expert.html

I don't understand the circuit graphic, but I can explain the numbers:

the program just does some random stuff to show you the different things the simulator does. Watch the yellow cursor in the block of numbers in the right side of the screen to watch the CPU go through the instructions.

a9 00 : LDA #$00 : Load register A with value 00. A = 00

20 10 00 : JSR #$0010 : jump to subroutine at address $10. notice how it writes '04 00' at the end of the memory space (the block of numbers) -- it's remembering where it needs to return from the subroutine (RTS) to. So when it's done doing whatever it needed to do at $0010, it needs to go back to $0004.

E8 : INX : increment X : X = X+1 = 1

88 : DEY : decrement Y : Y = Y-1 = -1 (FF means -1)

E6 0F: INC $0F : increments the value at address 0f (which is the end of the first line, initially set to $40, changing it to $41)

38 : SEC : Sets the "Carry" flag bit of the CPU to trick it into thinking that it was doing some adding and needed to do a carry. You should see that in the part where it says "nv‑BdIzc", the c becomes a capital.

69 02 : ADC #$02 : Add with Carry to A. A = A + 02 + Carry = 00 + 02 + 1 = 3.

60 : RTS : Return from subroutine. You'll see the yellow cursor move to the end of the memory space, and access the 04 00 it stored earlier, and then it goes back to address 0004.

4c 02 00 : JMP $0002 : Jump to address $0002 (this is like JSR above, but doesn't need an RTS call later).

then it juts does everything over and over again, except it's skipping the LDA #$00 instruction.

Here's a list of all the instructions and their corresponding numbers:

http://www.thegshi.org/faqs/6502_Instruction_Set.txt

Here's what the instructions do (not the clearest explanations..):

http://www.6502.org/tutorials/6502opcodes.html

Link to comment
Share on other sites

Nice find smoz.

The 6502 was a beast. It and its variants were used in a lot of early computers (Apple I and II, Commodore 64, just to name a few) as well as the Atari 2600, and of course the NES.

It's a shame that the SNES processor, a 65C816 variant, was actually backwards compatible with the 6502 and could run the full instruction set when put in 8-bit mode. This means that the SNES would have been able to play NES games as well, given all the other proper hardware needed or some way to "emulate" the rest of the NES hardware.

Unfortunately, Nintendo shot this down, since they wanted everyone to own a NES and a SNES.

Link to comment
Share on other sites

Nice find smoz.

The 6502 was a beast. It and its variants were used in a lot of early computers (Apple I and II, Commodore 64, just to name a few) as well as the Atari 2600, and of course the NES.

It's a shame that the SNES processor, a 65C816 variant, was actually backwards compatible with the 6502 and could run the full instruction set. This means that the SNES would have been able to play NES games as well, given all the other proper hardware needed or some way to "emulate" the rest of the NES hardware.

Unfortunately, Nintendo shot this down, since they wanted everyone to own a NES and a SNES.

Yeah, the SNES CPU instructions are pretty much the same as the 6502/NES instructions. That was a problem I had originally when getting into hacking NHLPA 93, not being able to find anything for the specific CPU.... before realizing it was 6502 instructions.

I didn't realize they purposely made them incompatible... Did they even sell the NES concurrently with the SNES, I don't know?

Link to comment
Share on other sites

Yep, when the SNES came out the NES was still strong. NES also got a facelift with a top loading unit in 1993 which is actually pretty rare now and goes for some good $ (I own one, no more blinking screen!)

I remember reading about them not wanting backwards compatibility in Retro gamer magazine.

Link to comment
Share on other sites

Oh yeah, I remember now.. I rented the SNES a lot, but only had an NES at home, until i suppose 94 when we got a SNES and a Genesis for christmas. (quite the christmas!)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...