6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 11:43 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: RAM question
PostPosted: Wed Aug 16, 2023 3:30 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 137
Hi Guys,

Reading up on the W65C02, it says you need RAM at the bottom for stack etc.

But, I'm just wondering is it possible to get away with just a 32K bank up top having address wire 15 on the RAM connected to address line 16 on the CPU (having the address vector to point to 32768 and the program start from there).

Is the bottom half of RAM absolutely required if you aren't using the stack? Or does the bottom half get used for other purposes?

Many thanks. :D


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM question
PostPosted: Wed Aug 16, 2023 3:45 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
http://wilsonminesco.com/6502primer/MemMapReqs.html (page 3 of the 6502 primer) should answer your questions, and tell why it is the way it is.  Briefly though, there will be very little you can do without the hardware stack (no subroutines, no interrupts, and certain software techniques become impossible too), and also certain things really require page 0, ie, addresses $0000-00FF, since these are basically used as processor registers for indirect addressing (as well as faster access to commonly used variables).  There are still various ways however that you could use a 32KB RAM the way I think you have in mind; it's just that ranges will show up at more than one address range—which is not a problem as long as you keep certain simple things in mind in your programming.

_________________
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: RAM question
PostPosted: Wed Aug 16, 2023 3:54 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 137
Thanks for the explanation Garth.

So, it looks like you can get away with what I was proposing, for more of a "Hello World" type project, and get my feet wet again, as long as I avoid "PHA, PLA, PHX, PLX, PHY, PLY, PHP, PLP, JSR, RTS, or RTI (and interrupts), TSX and TXS.


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM question
PostPosted: Wed Aug 16, 2023 4:16 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8428
Location: Southern California
If you do something like LDA #'H', STA <I/O_register>, LDA #'E', STA <I/O_register>, LDA #'L', STA <I/O_register>, etc., or even LDA <addr>,X, STA <I/O_register>, INX in a loop (where <addr> is the address of the string itself, not a variable that tells where the string is), you could get away without RAM in page 0 or 1, but you would not be able to put the address of the string in a variable and do LDA (ZP),Y, STA <I/O_register>, INY, in a loop.  A 6502 computer with no RAM in page 0 or page 1 would not be totally incapacitated, but would nevertheless be rather worthless.

_________________
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: RAM question
PostPosted: Wed Aug 16, 2023 6:37 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
(Over in the land of Acorn enthusiasts, there's a fault diagnostic test ROM which doesn't use any RAM at all - so there are indeed situations where the stack is optional.)


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM question
PostPosted: Wed Aug 16, 2023 10:29 am 
Offline
User avatar

Joined: Mon Mar 06, 2023 9:26 am
Posts: 84
Location: UK
The scheme you're suggesting seems to be that the 6502's A[0, 13] connect to the RAM's A[0, 13] and then the 6502's A15 connects to the RAM's A14. That would give you the bottom 16k of the RAM chip twice, in the bottom 32k of the address range, and then the top 16k twice in the top 32k. This doesn't seem very useful. You'd be better off just connecting the 6502's address lines to the same on the RAM, and leaving A15 unconnected. That would just give you the whole RAM twice.

_________________
probably the youngest person on this forum


Top
 Profile  
Reply with quote  
 Post subject: Re: RAM question
PostPosted: Wed Aug 16, 2023 11:08 am 
Offline

Joined: Sun Jul 11, 2021 9:12 am
Posts: 137
allisonlastname wrote:
The scheme you're suggesting seems to be that the 6502's A[0, 13] connect to the RAM's A[0, 13] and then the 6502's A15 connects to the RAM's A14. That would give you the bottom 16k of the RAM chip twice, in the bottom 32k of the address range, and then the top 16k twice in the top 32k. This doesn't seem very useful. You'd be better off just connecting the 6502's address lines to the same on the RAM, and leaving A15 unconnected. That would just give you the whole RAM twice.


Ah! That explains the problem I was having all afternoon but have since resolved (but couldn't understand exactly how I resolved it). I had a program starting at 32768 and just doing a jmp $8000 for an endless loop but the reset vector kept pointing the start to 49152 most likely due to the reasoning you just described. That gives me something to look at in the morning. :D

Aside from that I actually had a huge win today! What I did was, wired up a Raspberry Pi Pico and programmed it to be a big ROM (for the moment, RAM is the next step which should be pretty trivial) and am making the W65C02 run directly from that, with no additional components. Even the clock is supplied by the Pico.

For me, I think this will be an invaluable setup initially, as I will be able to prototype things faster (in theory :lol: ). No flashing of ROM's etc, just drop the 6502 code on to the Pico and off you go.

With some very tight coding I have this setup running next to me right now at 2 MHz! Again, the actual 6502 is very basic right now as I haven't created write functionality yet.

Attachment:
2mhz.jpg
2mhz.jpg [ 43.77 KiB | Viewed 4951 times ]


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 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: