6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sun Nov 24, 2024 10:16 pm

All times are UTC




Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
PostPosted: Sun Apr 23, 2000 4:08 pm 
Hi Guys,

i have a question about the 6502 processor's stack pointer.

1. how big is the stack area of memory and what does it store and in what format?
2. what does the stack pointer store, a memory location(to what) or a position number within the stack area of memory(e.g. location 2)

Cheers

Tony


Report this post
Top
  
Reply with quote  
PostPosted: Tue Apr 25, 2000 5:07 am 
Tony,

The stack pointer in a 65(C)02 is implemented as an 8-bit register that provides an index into the area of memory between 0x100 and 0x1ff. This is part of the main memory map (unlike some microcontrollers that have a seperate memory map for their stacks?). It is byte aligned and contains a mixture of both 'system' and 'user' information. The system information is typically return addresses held, if memory serves, as low-byte then high-byte. Obviously user information can be in any format.

I hope this helps.

Regards,

Simon J


Report this post
Top
  
Reply with quote  
PostPosted: Tue Apr 25, 2000 5:07 am 
Tony,

The stack pointer in a 65(C)02 is implemented as an 8-bit register that provides an index into the area of memory between 0x100 and 0x1ff. This is part of the main memory map (unlike some microcontrollers that have a seperate memory map for their stacks?). It is byte aligned and contains a mixture of both 'system' and 'user' information. The system information is typically return addresses held, if memory serves, as low-byte then high-byte. Obviously user information can be in any format.

I hope this helps.

Regards,

Simon J


Report this post
Top
  
Reply with quote  
PostPosted: Fri Apr 28, 2000 10:44 am 
If I remember correctly, when a JSR instruction is executed, the current program counter is pushed on the stack + or - 2 (something strange like that). Why isn't the return adddress (JSR + 3) put onto the stack for eventual RTS?

I've always wanted to know this.

Jim Lewandowski


Report this post
Top
  
Reply with quote  
PostPosted: Fri Apr 28, 2000 4:25 pm 
Offline

Joined: Fri Aug 30, 2002 2:05 pm
Posts: 347
Location: UK
Hi Jim,

You said ...

If I remember correctly, when a JSR instruction is executed, the current program counter is pushed on the stack + or - 2 (something strange like that). Why isn't the return adddress (JSR + 3) put onto the stack for eventual RTS?

....

The return address-1 is pushed (or JSR +2 whichever you prefer to call it). Why? Well after the return address is pulled from the stack the program counter is incremented by one before the next instruction is fetched.

You know it all makes sense.

Lee.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC


Who is online

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