That doesn't help me understand sadly... But I'll see the book you providedGarth wrote: ↑Wed Jun 17, 2020 5:59 pmChapter 17 of the Eyes & Lichty programming manual mentioned earlier dedicates an entire page to diagramming every one of the addressing modes. It would be difficult for me to do any better than that.
Every instruction has an op code. That's the first byte of the instruction, and in some cases, the only byte. If there's more than one addressing mode available for that instruction, the op code also tells which one. JMP for example has two addressing modes on the NMOS 6502, one being direct, which has an op code of $4C, and the other being indirect, which has an op code of $6C.
Most instructions also include an operand, which is a second byte and possibly a third byte of the instruction. In immediate addressing, the operand is the actual data, and your source code will specify that with the # symbol. An example is LDA #$41, where it puts $41 (ie, the number itself) into the accumulator. The complete machine-language instruction is A9 41, where $A9 is the op code and $41 is the operand.
Without the # symbol, the assembler will lay down the zero-page direct addressing mode version of the LDA instruction, op code $A5 instead of $A9. When the code runs, the processor will read address $0041 to get the data to put in the accumulator, instead of putting the number $41 itself in the accumulator.
Indirects are indicate by parentheses. The NMOS 6502 does not have a indirect LDA without indexing, but the CMOS one does; so just to keep things simpler for now, I'll use the CMOS's one and not get into indexing quite yet. If you write in your source code LDA ($41), the assembler will lay down op code $B2 instead of the $A9 or $A5 used above. When the code runs, the processor will read memory locations $0041 and $0042 to get the complete address of where to find the final desired number. So suppose addresses $0041 and $0042 contain $301B, and address $301B contains the byte $9A. $9A is what gets loaded into the accumulator.
There are many more addressing modes. I think you'll have to go step by step through a good programming manual, and practice. If you have nothing to practice on yet, there are online simulators like the one at http://skilldrick.github.io/easy6502/ which you might try.
The Addressing Modes
There are fourteen addressing modes available to the 6502, all of those plus two more on the 65C02,
and another nine categories available on the 65802 and 65816. Each mode allows the location of the data being
referenced by a given instruction to be specified in a different manner. The availability of many different
addressing modes on the 65x processors is one key to their power.
The data found in operand bytes of an instruction is only one part of the effective address specification;
the addressing modes, expressed using the correct address-mode syntax in the operand field of an assemblylanguage statement, cause the assembler to choose from among the instruction’s possible opcodes to one
specific to the addressing mode. Not all addressing modes are available for all instructions; but there is one
unique opcode for each combination of addressing mode and operation.
The addressing mode is the determinant of the effective address for an operation – the memory address
that the instruction will access for data or to transfer control within the program. For a few of the 65x
addressing modes, the effective address is provided in the operand field of the instruction. But for most of
them, formation of the effective address involves an address calculation, that is, the addition of two or more
values. The addressing mode used with a given instruction indicates where these values are to come from and
how they are to be added together to form the effective address. This effective address calculation has as many
forms as there are addressing modes.
An important aspect of effective address calculation on the 65802 and 65816, to be considered in
addition to the addressing modes themselves, is the state of the x index-register select flag and, to a lesser
extent, the m memory/accumulator select flag, both in the status register. In a sense, the x flag, for example,
extends the addressing mode specification part of an instruction, which uses an indexed addressing mode, by
determining whether or not an eight-bit or sixteen-bit index register is to be used. For every one of the indexed
addressing modes, there are two similar methods of forming an effective address, depending on the setting of
the index-register select flag. Pay special attention to the status and effects of the select flags.
In the following pages are graphic and written presentations of each of the addressing modes,
illustrating the effective address formation, complete with a listing of the processors on which, and the
instructions to which, each addressing mode is available. A sample of the assembler syntax used to invoke each
one is included as well.
It doesn't help about 14 addressing nodes.. Reading it only overwhelms me to think because I'm still beginner in 6502 coding stuff.
And as for EASY6502, I understand everything to the point of Branching page except "BRK", "CPX", and the following:
is the stack pointer. I won’t get into the stack yet, but basically this register is decremented every time a byte is pushed onto the stack, and incremented when a byte is popped off the stack.
And reading the next part:
I know this part, about the Addressing locations and memory stuff of Address Locations. So I feel like we're on the wrong side of something of misunderstanding.Addressing modes
The 6502 uses a 16-bit address bus, meaning that there are 65536 bytes of memory available to the processor. Remember that a byte is represented by two hex characters, so the memory locations are generally represented as $0000 - $ffff. There are various ways to refer to these memory locations, as detailed below.
With all these examples you might find it helpful to use the memory monitor to watch the memory change. The monitor takes a starting memory location and a number of bytes to display from that location. Both of these are hex values. For example, to display 16 bytes of memory from $c000, enter c000 and 10 into Start and Length, respectively.
I'm confused on that one since I don't know what do they mean "enter c000 and 10 into Start and Length" if I'm learning to program NES, as both console are same code yet different functionality, likeFor example, to display 16 bytes of memory from $c000, enter c000 and 10 into Start and Length, respectively.
These load color HEX code into selected Address, and that Address $200+ is the display of pixel from left to right then downward, then left to right. I don't think these code would work with NES because of different system. I Hope you understand what I mean.