Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial value of stkp during initialization #12

Open
d0gtail opened this issue Sep 13, 2019 · 1 comment
Open

Initial value of stkp during initialization #12

d0gtail opened this issue Sep 13, 2019 · 1 comment

Comments

@d0gtail
Copy link

d0gtail commented Sep 13, 2019

Hi,

would it be safe (for consistency) to set stkp to 0xFD during initialization like it is done when reset() is called?

public:
...
 uint8_t y = 0x00;
 uint8_t stkp = 0xFD;
...

public:
// CPU Core registers, exposed as public here for ease of access from external
// examinors. This is all the 6502 has.
uint8_t a = 0x00; // Accumulator Register
uint8_t x = 0x00; // X Register
uint8_t y = 0x00; // Y Register
uint8_t stkp = 0x00; // Stack Pointer (points to location on bus)
uint16_t pc = 0x0000; // Program Counter
uint8_t status = 0x00; // Status Register

// Reset internal registers
a = 0;
x = 0;
y = 0;
stkp = 0xFD;
status = 0x00 | U;

@OneLoneCoder
Copy link
Owner

In principle yes, but philosophically no. CPUs and memories start up in unknown states, so they should always be issued a reset command. I get your point though, and it was an oversight by me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants