6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Nov 22, 2024 12:37 pm

All times are UTC




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: Complete newbie
PostPosted: Sun Sep 15, 2013 5:39 am 
Offline

Joined: Sun Sep 15, 2013 5:31 am
Posts: 2
Hello.
I am completely new to the 6502 microprocessor and have one fundamentally important question.
How do I program a singular 6502?
Do I connect it to a bus that contains an EEPROM with the start code beginning at address 0x00? I never understood what the websites spoke about.


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Sun Sep 15, 2013 5:49 am 
Offline
User avatar

Joined: Sat Sep 29, 2012 10:15 pm
Posts: 904
OK, I will assume that this is a serious question. Your question - how to program the 6502 is somewhat ambiguous and broad. I will try to answer what I think you are asking - what is the startup sequence for the 6502.

Upon reset, the processor will jump to a location pointed to by the reset vector located at address $FFFC. Excruciating details of how this happens are documented here: http://www.pagetable.com/?p=410

Commonly, the reset vector and the initial code is placed into some form of non-volatile memory (and EPROM will do).

_________________
In theory, there is no difference between theory and practice. In practice, there is. ...Jan van de Snepscheut


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Sun Sep 15, 2013 6:04 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8543
Location: Southern California
I see enso posted before I was done. I'll finish and post this anyway.

From the middle of the Memory Map Requirements page of the 6502 primer:
Quote:
Reset (RST): When the 6502's RST\ input gets pulled low and then brought back high, the 6502 starts its reset process, and gets the address to start executing program instructions from $FFFC-FFFD. Notice it does not start executing at address $FFFC, but reads it to get the beginning address of the routine where it should start executing. That routine will normally have to be in ROM.

Because the reset vector needs to already be in place to start the computer, it will normally be in ROM, and since its address is at $FFFC-FFFD, the highest addresses, ie, those near FFFF, are normally ROM. It could be the top 8KB, 16KB, 32KB, or other quantity. Then, since the reset routine needs to also be there to get the computer up and running, that is also in ROM. So for example if the reset routine starts at $E000, then $FFFC would contain 0 and $FFFD would contain $E0 (ie, low byte first), so the processor knows to start executing at $E000. (The same page in the primer will also tell why there's never ROM at address $0000.)

The 6502 primer has loads of stuff on building a 6502 computer, and a little bit about programming. It does assume you are acquainted with a few things like:
  • binary and hexadecimal number bases
  • common 74-family logic ICs and their functions
  • wire-OR'able open-drain or open-collector logic
  • very basic DC circuit theory
  • even more-basic AC circuit theory (involving capacitance and, to a lesser extent, inductors)
  • what a stack is (a last-on first-off storage area in memory-- it's in the software manual)
  • what the address and data buses are and generally how they are connected
  • Timing diagrams are in the data sheets and will not be repeated there.

If you are already acquainted with these (even if you're no expert), you're ready to jump in.

_________________
http://WilsonMinesCo.com/ lots of 6502 resources
The "second front page" is http://wilsonminesco.com/links.html .
What's an additional VIA among friends, anyhow?


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Sun Sep 15, 2013 7:30 am 
Offline

Joined: Mon Jan 07, 2013 2:42 pm
Posts: 576
Location: Just outside Berlin, Germany
Or, before you do anything with hardware, you might want to get to know the chip with an emulator first, that is, just software. There are a bunch of them out there that are very, very good, for instance py65mon (http://py65.readthedocs.org/en/latest/). See the list at http://www.6502.org/tools/ for more.


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Sun Sep 15, 2013 4:35 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8505
Location: Midwestern USA
Xander wrote:
How do I program a singular 6502?

Others have responded about this but I will interject that anyone new to the 6502 family should read the Western Design Center's assembly language programming manual (copy attached—the link at WDC's site is broken). This manual presupposes some programming knowledge, but does start with the basics and works up from there.

Attachment:
File comment: Assembly Language Programming
65816_prog_ref.pdf [1.73 MiB]
Downloaded 183 times

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Sun Sep 15, 2013 4:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10985
Location: England
Hi Xander: welcome! Yes, you need to connect an EPROM to the bus, at minimum, but as the others say, the code doesn't just start at zero.
Cheers
Ed


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Mon Sep 16, 2013 2:47 am 
Offline

Joined: Sun Sep 15, 2013 5:31 am
Posts: 2
Wyelp, that was a bit crappily worded.
I simply wanted to know where to put the startup code.
Thanks.


Top
 Profile  
Reply with quote  
 Post subject: Re: Complete newbie
PostPosted: Mon Sep 16, 2013 8:27 am 
Offline

Joined: Mon Mar 25, 2013 9:26 pm
Posts: 183
Location: Germany
The "startup code" can be anywhere in your address-space, but you need to set the start-address to the reset-vector of your 6502. This vector is located at $FFFC (LOW-byte) and $FFFD (HI-byte). The 6502 grabs the address from this location and executes a "jump" to the address stored there.
For instance: your startup-code is located at $C000, you have to put $00 at $FFFC and $C0 at $FFFD. If a reset occurs (like power on) the cpu will start executing your code at $C000.
Because of the location of those vectors (there are some more of them) at the end of the memory space, you will normally use a ROM (f.i. EEPROM) that covers the higher range of your address space and use RAM for the lower address space. This is also recommended, because your 6502 need at least RAM for the first two pages $0000 - $00ff (zero-page) and $0100 - $01ff (stack)

Mario.

_________________
How should I know what I think, until I hear what I've said.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: