6502.org
http://forum.6502.org/

[45] Interrupt
http://forum.6502.org/viewtopic.php?f=7&t=302
Page 1 of 1

Author:  Neison1 [ Tue Apr 18, 2000 3:32 am ]
Post subject:  [45.1] Interrupt

Dear All:

I met a problem. In 6502, the BRK is one byte instruction, But in the WDC's W65SC02, it has two byte, what's the meanings of the second byte?

Author:  simonj5 [ Tue Apr 18, 2000 9:02 am ]
Post subject:  [45.2] Interrupt

Hi,

A quick look at the 65c02 datasheet (I downloaded it from Western Design Center's FTP site) gives the following information:-

6.2 The BRK instruction for both the NMOS 6502 and 65C02 is a 2 byte instruction. The NMOS device simply skips the second byte (i.e. doesn't care about the second byte) by incrementing the program counter twice. The 65C02 does the same thing except the assembler is looking for that second byte as a "signature byte". With either device (NMOS or CMOS), the second byte is not used. It is important to realize that if a return from interrupt is used it will return to the location after the second or signature byte.

However, my old MOS Technology Programming Manual has an appendix that shows, as you said and as I recall, that BRK is a single byte instruction but it shows that the PC (program counter) + 2 followed by the PC is pushed onto the stack. The result is that the address pushed into the stack is two bytes after the address of the BRK instruction. So, in one sense BRK is a two byte instruction!

I hope this 'helps'.

:-)

Simon

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/