Hello,
what are exactly the state of the cpu registers and flags at startup
(or after a reset)? Datasheets and many docs on the net seems
not to answer this (perhaps obvious) question.
Thanks,
tano
cpu initial state
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
The interrupt-disable flag is set, the decimal flag is cleared, and the program counter is loaded with the value at FFFC-FFFD. Nothing else is guaranteed. In fact, on the NMOS 6502, even the decimal flag is not guaranteed after reset or interrupt. That fact that it is guaranteed on the CMOS ones is one of the many improvements that came with CMOS.
The 65816 appropriately has a few more guarantees. The data and program bank registers are zeroed, the high byte of the stack pointer is set to 01, the high bytes of the X and Y registers are zeroed, the 6502 emulation bit is set, and the direct-page register is zeroed.
Welcome to the forum. We've had quite a few legitimate new members join in the last several weeks.
The 65816 appropriately has a few more guarantees. The data and program bank registers are zeroed, the high byte of the stack pointer is set to 01, the high bytes of the X and Y registers are zeroed, the 6502 emulation bit is set, and the direct-page register is zeroed.
Welcome to the forum. We've had quite a few legitimate new members join in the last several weeks.
Thanks! I forget to specify that I intend the NMOS version.
Looking in emulators source code I noted that reset code
seems also to clear all registers (a, x and y), and set the Zero
flag. Naturally the stack pointer should be set to 0x01ff.
But I think these are additions in respect to the natural behavior.
Bye,
tano
Looking in emulators source code I noted that reset code
seems also to clear all registers (a, x and y), and set the Zero
flag. Naturally the stack pointer should be set to 0x01ff.
But I think these are additions in respect to the natural behavior.
Bye,
tano
GARTHWILSON wrote:
In fact, on the NMOS 6502, even the decimal flag is not guaranteed after reset or interrupt.
Indeed that seems to be random. The KIM-1 monitor ROM does not clear the decimal flag after reset. A major flaw and number 1 problem for new KIM-1 users in the old days. Second one was not connecting the +12V that was required for the cassette interface.
- GARTHWILSON
- Forum Moderator
- Posts: 8775
- Joined: 30 Aug 2002
- Location: Southern California
- Contact:
Quote:
Indeed that seems to be random. The KIM-1 monitor ROM does not clear the decimal flag after reset. A major flaw and number 1 problem for new KIM-1 users in the old days.