Re: 6502 stack register at reset

From: smf <smf_at_null.net>
Date: Sat, 25 Nov 2017 21:41:13 +0000
Message-ID: <5e3a6804-513f-ec44-4756-12aabac3ee07@null.net>
You'll have problems if:

1. you are looking at 16bit values and assume that the two bytes will be 
contiguous in ram.

2. you're trying to detect stack overflows and assuming that is the same 
as wrapping.

The simple fix might be to initialise the stack pointer, or you may want 
to change the assumptions in the code.

On 25/11/2017 21:03, Spiro Trikaliotis wrote:

> Hello,
>
> * On Sat, Nov 25, 2017 at 08:50:21PM +0100 didier derny wrote:
>> Is there any 6502 starting with an initialized stack register at reset ?
>>
>> a few month ago I was struggling with a strange bug...
>>
>> the program was crashing or working randomly
>>
>> I discovered that the machine had a stack register never initialized
> But: Why is this a problem? I would expect the stack pointer just to
> wrap around.
>
> That is, if you have RAM at $0100-$01FF and you do not use that area for
> anything else, why should the CPU crash at all as long as you do not
> push more than 256 byte on it?
>
> Can anyone enlighten me?
>
> Regards,
> Spiro.
>

       Message was sent through the cbm-hackers mailing list
Received on 2017-11-25 22:03:38

Archive generated by hypermail 2.2.0.