GARTHWILSON wrote:
Hugh Aguilar wrote:
BTW: There is a bug in CMOVE --- I'm surprised that none of you 6502 have pointed that out yet.
Care to elaborate? I've never seen the bug; but not long into my 6502 Forth experience, I saw that I was virtually never moving a whole page or more, so I wrote a shorter, faster version and called it QCMOVE, the "Q" being for "quick," and I use that for moving less than a page, like for moving strings. (I still left CMOVE there, but seldom if ever use it.)
The bug was in my CMOVE that I wrote myself in the document. I have a new version now that should work --- still untested though, because I haven't yet written a simulator.
GARTHWILSON wrote:
Quote:
A better use of resources might be to just upgrade the 65c02's weak support for ISRs.
Huh?? The '02 has possibly the best interrupt response of any 8-bitter out there.
Well, the Z80 was more convenient to use --- you didn't have to test I/O ports to determine what caused the interrupt --- you got sent down a vector to the appropriate ISR (I have something quite similar now in the 65VM02 design).
The Z80 interrupt latency was higher than the 6502 though --- you are right that the 6502 had the fastest interrupt response of any 8-bitter of its day.
The story on the ARM is that the Acorn computer used the 6502, but they needed a more powerful processor. They liked the 6502's fast interrupt response time though, so they didn't want to switch to the MC68000 because it has a slow interrupt response (saving all those 32-bit registers takes a lot of time). For reasons unknown, they rejected the 65c816, although that would seem to be the obvious choice. They built the ARM (Acorn Risc Machine) instead, and it has register banks for ISRs so no need to save and restore registers to the return-stack. Later the ARM got sold to an American company and the ARM acronym came to mean: Advanced Risc Machine.
GARTHWILSON wrote:
Quote:
When doing an interrupt, after saving the registers, D should be set to 0 and A should be set to an indicator of what caused the interrupt. This way the ISR doesn't have to poll the I/O ports to figure out what caused the interrupt and what needs to be done --- it could just do a JVM to get to the correct ISR --- so you would effectively have 128 different interrupts, rather than just one like on the 65c02 (I got this idea from the Z80).
The 65c02 does clear the D bit automatically as part of the interrupt sequence. Having lots of interrupt inputs and vectors would be nice though. The interrupt vectors could be in processor interrupt vector registers which would get loaded by the reset routine or when the interrupts are set up or changed. They shouldn't be in ROM.
No, when I said D I meant the D register of the 65VM02 (8-bit register that points to the page that the direct-page is located on).
I didn't mean the D-flag which indicates decimal-mode and is in the P register. I'm just leaving decimal support alone --- it is not something that I use --- it should be left alone though, for legacy code.
GARTHWILSON wrote:
I'm not sure it's that big a deal though. I poll only those interrupt sources that are enabled, and poll them in order of priority. So if a particular VIA has the highest-priority enabled interrupt, that VIA gets polled first. If it claims responsibility for the interrupt, the others don't get polled at all. If it has more than one interrupt source within the VIA enabled, then further polling within the VIA must still be done since the VIA only has one interrupt output pin. The two or more enabled ones are polled in order of priority, and non-enabled ones are not looked at. Out of the dozens of possible interrupt sources on my workbench computer, I seldom have more than two or three enabled at a time.
Well, in my new 65VM02 design, this would be done in hardware rather than in software.
GARTHWILSON wrote:
Off the top of my head (where there's not much left
), I don't remember ever using Y in a machine-language ISR, so I don't save and restore it. X often doesn't get used in a machine-language ISR either, so sometimes saving and restoring that is a waste of time too. A is usually used, but I've also done ISRs that only increment a set of bytes in memory which you can do without
any processor registers or the overhead to save and restore them. (And polling can be started with BIT, again not needing A in some cases.)
Well, in my new 65VM02 design, I have a VIRQ interrupt in addition to IRQ and NMI. It saves A in addition to P and PC, but it doesn't save X and Y as they may not be modified in a short simple ISR.