André's 8-bit pages
Thankfully hosted by 6502.org.
(by Google)

65002 Addressing Modes

This page describes the addressing modes for the 65k line of processors.

The 65k is a 64  bit processor. As such the addressing modes of the 6502 are not sufficient to really use the up to 64  bit address space. Adding arbitrary new addressing modes would clutter the opcode space. So I defined a prefix bit that converts existing addressing modes into new, extended addressing modes.

Looking at the opcode table for example in this page you will notice that no new addressing modes are shown. Here the AM prefix code comes into play.

The addressing mode prefix bit AM allows to extend the existing addressing modes from zeropage (8  bit) and absolute (16  bit) to long (32  bit) and longlong (64  bit). The following table shows the modifications when AM is set.

Original Addressing ModeNew Addressing ModeComment
zplonguse a long (32  bit) address instead of a zeropage address
zp,Xlong,Xuse a long (32  bit) address instead of a zeropage address
zp,Ylong,Yuse a long (32  bit) address instead of a zeropage address
abslonglonguse a longlong (64  bit) address instead of an absolute address
abs,Xlonglong,Xuse a longlong (64  bit) address instead of an absolute address
abs,Ylonglong,Yuse a longlong (64  bit) address instead of an absolute address
(zp)[zp]from the given zeropage location, read a long address instead of an absolute address
(zp),Y[zp],Yfrom the given zeropage location, read a long address instead of an absolute address, then add YR
(zp,X)[zp,X]from the given zeropage location (plus XR as given by the addressing mode), read a long address instead of an absolute address
(abs)[abs]from the given absolute location, read a long address instead of an absolute address
(abs),Y[abs],Yfrom the given absolute location, read a long address instead of an absolute address, then add YR
(abs,X)[abs,X]from the given absolute location (plus XR as given by the addressing mode), read a long address instead of an absolute address
(zp)[[zp]]from the given zeropage location, read a quad (longlong) address instead of an absolute address
(zp),Y[[zp]],Yfrom the given zeropage location, read a quad (longlong) address instead of an absolute address, then add YR
(zp,X)[[zp,X]]from the given zeropage location (plus XR as given by the addressing mode), read a quad (longlong) address instead of an absolute address
(abs)[[abs]]from the given absolute location, read a quad (longlong) address instead of an absolute address
(abs),Y[[abs]],Yfrom the given absolute location, read a quad (longlong) address instead of an absolute address, then add YR
(abs,X)[[abs,X]]from the given absolute location (plus XR as given by the addressing mode), read a quad (longlong) address instead of an absolute address
immimmunchanged
impliedimpliedunchanged
relrellongextend the relative offset from an 8 bit to a 32 bit value
relwiderelquadextend the relative offset from a 16 bit to a 64 bit value

With a simple translation not all new addressing modes would be supported. The indirect addressing modes normally (6502) read a word address, with the AM bit set they read a long address - but for using a quad address another solution is needed. Thus the indirect opcodes are mirrored, and extended from long to quad (longlong) indirect addressing modes. Opcode Row LSB 1 is mirrored to row LSB 3, as well as row LSB 2 is mirrored to LSB 7. These values are marked with a green background in the table in the opcode structure page. The LSB 3 and 7 rows need to have the AM prefix set to 1, and use the quad (longlong) indirect addressing modes.

Also note that there a are no indirect addressing modes that take a long or quad (longlong) value as indirect address. This can be overcome with the offset prefix though.

As has been shown in the Prefixes page two prefix bits can be used to add a register value to an operand. This creates PC-relative, Stack-relative and B-register-relative addressing modes. The table from that page is reproduced here for convenience:

OF1/0RegisterRegister NameSyntaxExamples
00-no register value added-LDA $1234
01PCProgram CounterAddress prefix P,LDA P,$1234; LDA (P,$12),Y
10SRStack PointerAddress prefix S,LDA S,$1234; LDA [S,$23,X]
11BRBase RegisterAddress prefix B,LDA B,$1234; LDA B,$12,X

Note that the size of the address read from the indirect address is defined by the addressing mode alone (which is also determined by the AM prefix bit).

This section describes an overview on the addressing modes of the 65k processor. An addressing mode determines effective address of an operand (no matter what size the operand is). The addressing modes are described in detail below.

NameAlternative NamePrefixOperand LengthSyntaxOriginDescription
Implied0Implied by the operation
Accumulator0Accumulator operation
Address2absThe parameter following the opcode is an address (16 bit; for JMP, JSR, JPU)
Address LongAM=14long65kThe parameter following the opcode is an address (32 bit; for JMP, JSR, JPU)
Address QuadAM=18quad65kThe parameter following the opcode is an address (32 bit; for JMP, JSR, JPU)
Immediate1#byteThe immediate addressing mode uses the opcode parameter directly, without further lookup. Here it is a byte parameter
Immediate 16bitWide immediateRS=012#word65kThe immediate addressing mode uses the opcode parameter directly, without further lookup. Here it is a word (16bit) parameter
Immediate 32bitLong immediateRS=104#long65kThe immediate addressing mode uses the opcode parameter directly, without further lookup. Here it is a long (32bit) parameter
Immediate 64bitRS=118#quad65kThe immediate addressing mode uses the opcode parameter directly, without further lookup. Here it is a quad (64bit) parameter
E indirect0(E)65kE-register indirect: the effective address is taken from the E register.
Zeropage1zpZeropage address; The effective address of the operand is a zeropage address (i.e. 8bit)
Zeropage indexed with XZeropage X-indexed1zp,XZeropage address, plus content of XR; The effective address of the operand is the opcode parameter (zeropage address), plus the value of the X register
Zeropage indexed with YZeropage Y-indexed1zp,YZeropage address, plus content of YR; The effective address of the operand is the opcode parameter (zeropage address), plus the value of the Y register
Absolute 16bitAbsolute2abs16 bit address; The effective address of the operand is the word address (i.e. 16 bit) given as opcode parameter
Absolute 16bit indexed with XAbsolute X-indexed2abs,X16 bit address, plus content of XR; The effective address is the opcode parameter (word address), plus the value of the X register
Absolute 16bit indexed with YAbsolute Y-indexed2abs,Y16 bit address, plus content of YR; The effective address is the opcode parameter (word address), plus the value of the Y register
Absolute 32bitLong absoluteAM=14long65k32 bit address; The effective address is the opcode parameter, which is a long address (i.e. 32 bit)
Absolute 32bit indexed with XLong absolute X-indexedAM=14long,X65k32 bit address, plus content of XR; The effective address is the opcode parameter (long address), plus the value of the X register
Absolute 32bit indexed with YLong absolute Y-indexedAM=14long,Y65k32 bit address, plus content of YR; The effective address is the opcode parameter (long address), plus the value of the Y register
Absolute 64bitQuad absoluteAM=18quad65k64 bit address; The effective address is the opcode parameter, which is a quad address (i.e. 64 bit)
Absolute 64bit indexed with XQuad absolute X-indexedAM=18quad,X65k64 bit address, plus content of XR; The effective address is the opcode parameter (quad address), plus the value of the X register
Absolute 64bit indexed with YQuad absolute Y-indexedAM=18quad,Y65k64 bit address, plus content of YR; The effective address is the opcode parameter (quad address), plus the value of the Y register
Zeropage indirect 16bitZeropage indirect1(zp)cmosLoad effective 16 bit address from zeropage location given; Load effective word (16bit) address from zeropage location given as parameter.
Zeropage indirect 16bit indexed with YZeropage indirect Y-indexed1(zp),YLoad effective 16 bit address from zeropage location given, then add content of YR; The effective address is computed as the word (16bit) address read from the zeropage location given as parameter plus the value of the Y register. The resulting address may be larger than 16bit due to overflow when Y is added.
Zeropage indexed with X indirect 16bitZeropage X-indexed indirect1(zp,X)Load effective 16 bit address from zeropage location given plus content of XR; The effective word (16bit) address is read from the location that is computed as the zeropage location given as parameter plus the value of the X register
Absolute indirect 16bitAbsolute indirect2(abs)Load effective 16 bit address from absolute location given; The effective word (16bit) address is read from word location given as parameter.
Absolute indirect 16bit indexed with YAbsolute indirect Y-indexed2(abs),Y65kLoad effective 16 bit address from absolute location given, then add content of YR; The effective address is computed as the word (16bit) address read from the word location given as parameter plus the value of the Y register. The resulting address may be larger than 16bit due to overflow when Y is added.
Absolute indexed with X indirect 16bitAbsolute X-indexed indirect2(abs,X)cmosLoad effective 16 bit address from absolute location given plus content of XR; The effective word address is read from the location that is computed as the word location given as parameter plus the value of the X register
Zeropage indirect 32bitLong Zeropage indirectAM=11[zp]65kLoad effective 32 bit address from zeropage location given; The effective long (32bit) address is read from zeropage location given as parameter.
Zeropage indirect 32bit indexed with YZeropage long indirect Y-indexedAM=11[zp],Y65kLoad effective 32 bit address from zeropage location given, then add content of YR; The effective address is computed as the long (32bit) address read from the zeropage location given as parameter plus the value of the Y register. The resulting address may be larger than 32bit due to overflow when Y is added.
Zeropage indexed with X indirect 32bitZeropage X-indexed long indirectAM=11[zp,X]65kLoad effective 32 bit address from zeropage location given plus content of XR; The effective long (32bit) address is read from the location that is computed as the zeropage location given as parameter plus the value of the X register
Absolute indirect 32bitAbsolute long indirectAM=12[abs]65kLoad effective 32 bit address from absolute location given; The effective long (32bit) address is read from word location given as parameter.
Absolute indirect 32bit indexed with YAbsolute long indirect Y-indexedAM=12[abs],Y65kLoad effective 32 bit address from absolute location given, then add content of YR; The effective address is computed as the long address read from the word location given as parameter plus the value of the Y register. The resulting address may be larger than 32bit due to overflow when Y is added.
Absolute indexed with X indirect 32bitAbsolute X-indexed long indirectAM=12[abs,X]65kLoad effective 32 bit address from absolute location given plus content of XR; The effective long (32bit) address is read from the location that is computed as the word location given as parameter plus the value of the X register
Zeropage indirect 64bitZeropage quad indirectAM=11[[zp]]65kLoad effective 64 bit address from zeropage location given; The effective quad (64bit) address is read from zeropage location given as parameter.
Zeropage indirect 64bit indexed with YZeropage quad indirect Y-indexedAM=11[[zp]],Y65kLoad effective 64 bit address from zeropage location given, then add content of YR; The effective address is computed as the quad (64bit) address read from the zeropage location given as parameter plus the value of the Y register
Zeropage indexed with X indirect 64bitZeropage X-indexed quad indirectAM=11[[zp,X]]65kLoad effective 64 bit address from zeropage location given plus content of XR; The effective quad (64bit) address is read from the location that is computed as the zeropage location given as parameter plus the value of the X register
Absolute indirect 64bitAbsolute quad indirectAM=12[[abs]]65kLoad effective 64 bit address from absolute location given; The effective quad (64bit) address is read from word location given as parameter.
Absolute indirect 64bit indexed with YAbsolute quad indirect Y-indexedAM=12[[abs]],Y65kLoad effective 64 bit address from absolute location given, then add content of YR; The effective address is computed as the quad address read from the word location given as parameter plus the value of the Y register
Absolute indexed with X indirect 64bitAbsolute X-indexed quad indirectAM=12[[abs,X]]65kLoad effective 64 bit address from absolute location given plus content of XR; The effective quad (64bit) address is read from the location that is computed as the word location given as parameter plus the value of the X register
Relative1relrelative addressing modes, used in branches; from -128 to +127
Relative 16bitWide relativeRS=012relwide65krelative addressing modes, used in branches; from -32768 to +32767
Relative 32bitLong relativeRS=104rellong65krelative addressing modes, used in branches; from -2^32 to +2^32-1
Relative 64bitQuad relativeRS=118relquad65krelative addressing modes, used in branches; from -2^64 to +2^64-1
Relative (BSR)1relrelative addressing modes, used in BSR; from -128 to +127
Relative 16bit (BSR)Wide relative2relwide65krelative addressing modes, used in BSR; from -32768 to +32767
Relative 32bit (BSR)Long relativeAM=14rellong65krelative addressing modes, used in BSR; from -2^32 to +2^32-1
Relative 64bit (BSR)Quad relativeAM=18relquad65krelative addressing modes, used in BSR; from -2^64 to +2^64-1
 

Disclaimer

All Copyrights are acknowledged. The information here is provided under the terms as described in the license section.

Last updated 2012-04-23. Last modified: 2012-04-29
follow

Follow my 8-bit tweets on Mastodon (In new window) or Bluesky

discuss

Discuss my site on this 6502.org forum thread

(Forum registration required to post)

hot!

Dive into the retro feeling and build yourself a Micro-PET or a Multi-board Commodore 4032 replica

Need more speed? Speed up your 6502 computer with this 10 MHz 6502 CPU accelerator board

Interested in electronics design? Look at the design lesson I got from Bil Herd, the hardware designer of the C128

Want 64bit? - pimp the 6502 with the 65k processor design!