[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 65816 Loop Question
- Subject: Re: 65816 Loop Question
- From: dempson@actrix.gen.nz (David Empson)
- Date: Thu, 11 Apr 2002 01:21:22 +1200
- Newsgroups: comp.sys.apple2
- Organization: Empsoft
- References: <xnJs8.289204$2q2.26680870@bin4.nnrp.aus1.giganews.com> <1faf9wz.1jevr4pvxu9djN%dempson@actrix.gen.nz> <URMs8.64456$r7.5683997@bin8.nnrp.aus1.giganews.com>
- User-agent: MacSOUP/2.4.2
- Xref: archiver1.google.com comp.sys.apple2:18793
Bryan Parkoff <BParkoff@satx.rr.com> wrote:
> Thank you for the answer. It does make sense that I understood
> completely.
>
> You use two words -- Direct and Indirect. Indirect is like pointer.
Correct, but it looks like you didn't understand "Direct".
"Direct" in this context refers specifically to the "direct page", i.e.
the 256 bytes starting at the location pointed to by the D register
(which is always within the first 64 KB). There are other addressing
modes which are also only able to access memory within the first 64 KB.
I think that "Direct" page was a poor choice for its name, because of
the resulting confusing names for addressing modes. It was originally
called "Zero" page on the 6502 and 65C02, where the "zero" implies that
it starts at location zero. The only thing that changed is that the
start address can be set anywhere within the first 64 KB.
It might have been cleared if they had called it something like the
"Short" page or "Frame" page. Native 65816 applications often use the D
register like a frame pointer.
> If we say -- Direct Direct, it can mean to access inside 64KB.
No. That isn't a valid concept - there is no "Direct Direct" addressing
mode.
Any access to the direct page (or indexed from an address within the
direct page) can only fall within the first 64 KB.
An absolute address might also fall within the first 64 KB (if the data
bank register is set to zero).
> If we say -- Direct Indirect, it can mean to access inside and outside
> 64KB. It looks neat.
Not exactly. The addressing modes "Direct Indirect", "Direct Indirect
Indexed" (post-indexed) and "Direct Indexed Indirect" (pre-indexed) all
fetch a pointer from direct page and then access a memory location
within the current data bank. In native mode, this can cross a bank
boundary.
The addressing mode "Direct Indirect Long Indexed" can access the entire
16 MB address space.
Here is the full set of 65816 addressing modes:
1. Immediate #nn, #nnnn
2. Absolute aaaa
3. Absolute Long aaaaaa
4. Direct dd
5. Accumulator A
6. Implied
7. Direct Indirect Indexed (dd),Y
8. Direct Indirect Long Indexed [dd],Y
9. Direct Indexed Indirect (dd,X)
10. Direct Indexed with X dd,X
11. Direct Indexed with Y dd,Y
12. Absolute Indexed with X aaaa,X
13. Absolute Long Indexed with X aaaaaa,X
14. Absolute Indexed with Y aaaa,Y
15. Program Counter Relative looks like aaaa, +/- 128 offset
16. Program Counter Relative Long looks like aaaa, +/- 32K offset
17. Absolute Indirect (aaaa)
18. Direct Indirect (dd)
19. Direct Indirect Long [dd]
20. Absolute Indexed Indirect (aaaa,X)
21. Stack
22. Stack Relative dd,S
23. Stack Relative Indirect Indexed (dd,S),Y
24. Block Move
I've already explained the various "Direct" modes use an 8-bit address.
They can access 256 bytes starting at the D register possibly after
adding an index register (limited to the first 64KB of the address
space). The indirect variants end up fetching a pointer from somewhere
within the first 64K, which is then treated as an absolute or absolute
long address.
The "Absolute" modes (not including the "Absolute Long" modes) use a
16-bit address. They can access any location within the current data
bank. In native mode, then can index beyond the bank boundary. The
indirect variants are only used with the JMP, JML and JSR instructions,
and are used to look up tables of function pointers.
The "Absolute Long" modes use a 24-bit address. They can access the
entire address space.
The "Stack Relative" modes work similarly to the "Direct" modes - they
use an 8-bit offset from the stack pointer. Mode 22 (stack relative) is
equivalent to mode 4 (direct) except that S is used as the base address
instead of D. Similarly, mode 23 (stack relative indirect indexed) is
equivalent to mode 7 (direct indirect indexed).
Both of the stack relative modes are limited to the first 64 KB to fetch
the data from the stack. The pointer fetched in mode 23 is treated as
an absolute address, so the subsequent indexing with Y can cross a bank
boundary.
--
David Empson
dempson@actrix.gen.nz