Date : Wed, 27 Oct 2004 12:24:33 +0200
From : John Kortink <kortink@...>
Subject: Re: &D00
On Wed, 27 Oct 2004 10:57:34 +0100, Richard Gellman wrote:
>[...]
>
>Eep! Don't want to RTI. On BBC Micros, there is almost never a need for
>a user program to use RTI. The 6502 guns all NMIs through the NMI vector
>address at the top end of the MOS ROM. This vector points to a location
>in the MOS which in turn indirects through soft NMI vectors.
Eh ? There's no soft vector anywhere in NMI handling.
NMI jumps to (&FFFA) which is &0D00 on both BBC and
Master.
>The MOS calls this vector through a normal JSR-JMP construct[1], so
>return should be by RTS, not RTI.
Eh again ?
>The difference between the two being of course that RTI also pops the
>status register off the stack in addition to the return address.
>
>The same applies for software interrupts (yes, the 6502 has them.. its
>the BRK instructions) and IRQs. In fact, the 6502 sends IRQ and BRK
>through the same ROM vector, then MOS distriguishes which it is, and
>calls the appropriate software vector (BRKV. IRQ1V, or IRQ2V). NMIs are
>actually vectored slightly differently due to their nature. The MOS only
>permits "registered" entry points to intercept NMIs, which is why only
>the disk and net controllers use them (and also because they need to
>respond to service requests regardless of CPU state).
Triple eh ? What system are you talking about ? Certainly
not a regular BBC or Master.
>[1] The JSR-JMP construct is a cunning way of implementing JSR (addr).
>The basic code runs as follows:
>
>Store JMP (addr) opcode (&6C):
>LDA #&6C:STA &1000
>Store the address:
>LDA #LSBaddr: STA &1001
>LDA #MSBaddr: STA &1002
>Then JSR it:
>JSR &1000
>
>The JMP jumps to the code, but the RTS will return to the address the
>JSR was called from.
I don't know, cunning ? A well known, better (memory frugal,
shorter, faster, ...) way is :
LDA #MSB(addr - 1):PHA
LDA #LSB(addr - 1):PHA
RTS
and JSR to that. Supposing <addr> is not known until
runtime that is.
John Kortink
--
Email : kortink@...
Homepage : http://www.inter.nl.net/users/J.Kortink