Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.sys.apple2.programmer > #2205
| From | Scott Hemphill <hemphill@hemphills.net> |
|---|---|
| Newsgroups | comp.sys.apple2.programmer |
| Subject | Re: most efficient way to save/restore 6502 registers |
| References | <61723ee6-c434-48d0-9bb0-bd44b545c922@googlegroups.com> |
| Date | 2016-02-04 15:31 -0500 |
| Message-ID | <87mvrgi5fa.fsf@hemphills.net> (permalink) |
Mark Lemmert <mark.lemmert@gmail.com> writes: > I am wondering if anybody knows why the most Apple II assembly > subroutines save/restore registered via the stack (method 1 below), > instead of using variables (method 2 below)? > > And, what are the advantages and disadvantages are for each method? > > Thanks a lot for any insights! (1) I think you pretty much covered it. Note that if you do a lot of saving/restoring, you could (with both schemes) reduce the per instance memory usage by doing this: JSR XYSAVE ... JSR XYRESTORE You could even omit the call to XYRESTORE if XYSAVE manipulates the stack by putting the address to XYRESTORE on it, so that the RET from your subroutine automatically restores the registers. (2) If your subroutine calls itself recursively, you need to store the registers on a stack. (3) If your subroutine doesn't know which memory banks are switched in (e.g. when processing an interrupt) then you may not want to store the registers in memory. (4) Saving the registers in memory allows you to restore them multiple times. Scott -- Scott Hemphill hemphill@alumni.caltech.edu "This isn't flying. This is falling, with style." -- Buzz Lightyear
Back to comp.sys.apple2.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
most efficient way to save/restore 6502 registers Mark Lemmert <mark.lemmert@gmail.com> - 2016-02-04 11:41 -0800
Re: most efficient way to save/restore 6502 registers Scott Hemphill <hemphill@hemphills.net> - 2016-02-04 15:31 -0500
Re: most efficient way to save/restore 6502 registers Mark Lemmert <mark.lemmert@gmail.com> - 2016-02-04 19:22 -0800
Re: most efficient way to save/restore 6502 registers Michael Barry <barrym95838@yahoo.com> - 2016-02-04 20:21 -0800
Re: most efficient way to save/restore 6502 registers wssimms@gmail.com - 2016-02-04 21:20 -0800
csiph-web