6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 2:56 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Stack Requirements
PostPosted: Fri Oct 04, 2013 11:52 pm 
Offline
User avatar

Joined: Wed Jul 10, 2013 3:13 pm
Posts: 67
http://www.devili.iki.fi/Computers/Comm ... e_274.html

what does it mean
Stack Requirements: 13

_________________
JMP $FFD2


Top
 Profile  
Reply with quote  
 Post subject: Re: Stack Requirements
PostPosted: Sat Oct 05, 2013 12:15 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
James_Parsons wrote:
http://www.devili.iki.fi/Computers/Commodore/C64/Programmers_Reference/Chapter_5/page_274.html

what does it mean
Stack Requirements: 13

It means that the maximum stack space consumption during the subroutine call (ACPTR) is 13 bytes. An additional two stack bytes are used for the return address back to the calling program, which Commodore did not count as part of the kernel call's stack usage. ACPTR itself makes various internal subroutine calls to handshake the serial bus, which is where some of that stack space gets used.

Although the 6502's stack is tiny by current standards it can handle quite a few nested subroutines. Assuming the worst case, in which each subroutine pushes all registers for later restoration, 42 subroutines can theoretically be nested. I say "theoretically" because interrupts will also claim stack space. Plus when BASIC is running, the stack gets used for FOR-NEXT loops, as well as handling GOSUB-RETURN pairs. You can get an OUT OF MEMORY error in BASIC if too many GOSUBs or FOR-NEXT loops are nested. The choice of error for this situation is unfortunate, because there's plenty of memory when it happens. What is really happening is that the stack pointer has been driven too close to $00, leaving insufficient stack space for another GOSUB or FOR-NEXT.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Stack Requirements
PostPosted: Sat Oct 05, 2013 12:21 am 
Offline
User avatar

Joined: Fri Aug 30, 2002 1:09 am
Posts: 8545
Location: Southern California
From this page, it appears to be how many bytes' space it takes in the hardware stack (which is in page 1), not including the return address that gets put on it by your JSR that calls the routine. 13 bytes on that one is extraordinarily heavy stack usage. I looked at a lof of the following pages, and the other routines all took less, mostly zero to two.

It looks like you found a really good website there!

_________________
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: Stack Requirements
PostPosted: Sat Oct 05, 2013 12:42 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1949
Location: Sacramento, CA, USA
GARTHWILSON wrote:
... It looks like you found a really good website there!


That guide is a classic ... I still have the paper-and-ink version (well worn from extensive use in 1984) on my bedroom bookshelf.

Mike


Top
 Profile  
Reply with quote  
 Post subject: Re: Stack Requirements
PostPosted: Sat Oct 05, 2013 12:53 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8509
Location: Midwestern USA
barrym95838 wrote:
GARTHWILSON wrote:
... It looks like you found a really good website there!


That guide is a classic ... I still have the paper-and-ink version (well worn from extensive use in 1984) on my bedroom bookshelf.

Mike

At one time I had it memorized. Time and some failed synapses have forced me to start reading again. :lol:

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


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

All times are UTC


Who is online

Users browsing this forum: Google [Bot] and 30 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: