Date : Sat, 18 Mar 2006 12:53:20 +0000 (GMT)
From : Greg Cook <debounce@...>
Subject: Re: 1MHZ SCSI/ATA board
On Thu, 16 Mar 2006 10:44:23 +0100, John Kortink <kortink@...>
wrote:
> On Thu, 16 Mar 2006 07:39:20 -0000, "David Harper" wrote:
>
> >Having said this, indexing into the stack seems to be a far less
> common
> >technique in 6502 programming than in 80x86 programming. In the
> latter it is
> >standard, using stack structures indexed with BP, but I don't recall
> ever
> >having come across it to any significant extent in 6502 programs.
> >
> >How much have you good folk used the idea when writing 6502 code?
>
> I use it all the time in my code. It is an essential
> technique, to use the stack for all transient memory
> needs. Instead of (ab)using fixed locations.
Appropriate in places, but evidently the Postscript thing doesn't sit
comfortably on the 6502. It's a choice of last resort really.
> It does
> take a lot of discipline in getting it right, since
> your memory is not in a fixed location but needs to
> be addressed by page 1 + offset + X all the time. A
> mistake is easily made, especially having X correct
> all the time can be a little tricky (you sometimes
> need it for other purposes than a stack reference,
> and there can be complications with called routines
> that need it for both purposes, add things to the
> stack which you need to account for, etc.).
And John's used it cannily in GoMMC, I notice. His patch for Acorn DFS
replaces the hardware accesses with a routine that stuffs loads of
state on the stack and dashes off, via OSWORD &B0, to the GoMMC ROM
where there's room for code to unpack it all.
Also the MOS does stack-bashing in the extended vector code at &FF51,
which allows paged ROMs to hook the OS vectors into their routines.
(I disassembled enough of the GoMMC code to allow EDOS to send FDC
accesses to it. Had to use more of the jump table offsets, love the
hash technique ;-) Sadly, *CAT failed with a BRK at &0406, I couldn't
figure out how and when to make GoMMC put the handler there. As John
says, "Y = &FF : do NOT use. do not EVER use.")
Greg Cook
debounce@...
http://homepages.tesco.net/~rainstorm/
___________________________________________________________
To help you stay safe and secure online, we've developed the all new Yahoo!
Security Centre. http://uk.security.yahoo.com