Newsgroups: comp.sys.apple2.programmer Subject: Re: COP instruction From: dempson@actrix.gen.nz (David Empson) Date: Sun, 4 Jul 1999 13:41:34 +1200 Message-ID: <1duf6qn.1nr6o1p16f79zmN@dempson.actrix.gen.nz> References: <7lbv4f$fku$1@news.rt66.com> Organization: Empsoft X-Newsreader: MacSOUP 2.3 NNTP-Posting-Host: 202.49.157.176 X-Original-NNTP-Posting-Host: 202.49.157.176 X-Trace: 4 Jul 1999 13:40:13 NZST, 202.49.157.176 Lines: 37 Path: news1.icaen!news.uiowa.edu!news.physics.uiowa.edu!hammer.uoregon.edu!logbridge.uoregon.edu!newsfeed.berkeley.edu!news-stock.gip.net!news.gsl.net!gip.net!news.iprolink.co.nz!news.actrix.gen.nz!dempson Xref: news1.icaen comp.sys.apple2.programmer:10774 Charles Stephens wrote: > I am trying to be quite accurate, so I just want to make sure I got it > right. If a COP is decoded, I should push pc on the stack and set pc > to the vector and it is software's resposibility to skip over the > signature byte and return via a RTI? According to the 65816 data sheet, COP and BRK are implemented in exactly the same way. The cycle breakdown is: 1. Opcode fetch (BRK or COP) 2. Operand (signature) fetch 3. Push PBR (if in native mode) 4. Push PCH 5. Push PCL 6. Push P 7. Vector fetch low 8. Vector fetch high (First opcode for interrupt handler is fetched) This doesn't clearly state whether the pushed value of the program counter is pointing to the signature byte or after it. However, there is a clear description of this on page 255 of Eyes & Lichty, which says that the RTI will return two bytes after the COP or BRK, hence the stacked value is always two higher than the address of the COP or BRK. The signature byte is fetched and discarded by the CPU, and the program counter is incremented once more before it gets pushed. A coprocessor would have to be monitoring the data bus to see the signature byte, or go back and fetch it. A software interrupt handler would always go back and fetch the signature byte. -- David Empson dempson@actrix.gen.nz Snail mail: P.O. Box 27-103, Wellington, New Zealand