Hello, I'm back, still need assistences

Are you new to 6502, NES, or even programming in general? Post any of your questions here. Remember - the only dumb question is the question that remains unasked.

Moderator: Moderators

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Sat Jun 13, 2020 9:11 pm

DocWaluigean wrote:
Sat Jun 13, 2020 5:23 pm
Garth wrote:
Sat Jun 13, 2020 4:59 pm
You cannot rotate, shift, or add in the X & Y registers, nor S. You can compare X or Y with CPX or CPY, and that can affect the C flag. You cannot compare S though.
This one, I'm a little confused... I'm thinking the X and Y Register will NOT be affected by Overflow Flag?
Unless I'm forgetting something, the only instructions that will be affected (passive) by the oVerflow flag V are BVS and BVC. Arithmetic functions that actively set or clear the V flag are ADC and SBC, and then V's meaning is relevant for signed numbers, which you don't need to get into yet. V does have a nice benefit with the BIT instruction too. None of these involve X or Y.

Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
Mostly right. Actions on A, X, or Y can set the N flag.

Okay, ONLY Register A can use ADC and SBC, got it.
Right.

This one brings me interesting questions. Let's say that Register A has Carry Flag turn on, Register X has Negative Flag turn on, and Register Y has Zero Flag turn on. Through most recent operations, will the flag turn off and on many times when I use certain Registers?

-I use the Register A. The Carry Flag is turned on.
-Then I use Register X, which has Negative Flag turned on.
[Either Carry Flag is also turn on because Register A is still carrying number? Or if it turns off because I'm using Register X right now.]
-Then I use the Register A.
[Does the Negative Flag still remains on at this point? Or NOW it turns off the Negative Flag but it turns ON the Carry Flag?]
Then I used the Register Y, which has Zero Flag turn on.
[Does it turns off both the Negative Flag and Carry Flag, but NOW turns on the Zero Flag?]
Then I used the Register X Flag.
[Does it turn off the Zero Flag, and turns off the Carry Flag, but NOW turns on the Negative Flag?]
The flags are in the Processor status register P, not in A, X, or Y. They reflect the last action that affects them, regardless of whether that action was on A, X, or Y. So A does not have a C flag. P does. X does not have an N flag. P does. Etc.. There is only one C flag, one N flag, one Z flag, etc., not one for each register.

I can turn on 3 switches using 3 Registers? Which Registers can't turn on certain Flags? And I'm wondering the Stack Pointer as a different Register, as it's not part of 3 Registers.
Right. The stack pointer has a very specific purpose that's separate from what A, X, and Y are used for. As for switches, I'm not sure what you're asking.
I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
There is only one carry flag, and it's in the P register. There aren't separate ones in A, X, and Y. The C, N, Z, and V flags are used for conditional branch instructions to know whether to branch or not. These include BCC, BCS, BPL, BMI, BNE, BEQ, BVC, and BVS, respectively, for clear and set conditions.
http://WilsonMinesCo.com/ lots of 6502 resources

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Sat Jun 13, 2020 9:21 pm

DocWaluigean wrote:
Sat Jun 13, 2020 7:08 pm
In this case you can simply say SBC/CMP subtracts a number from another, but if you want to get technical, numbers are specified as operands in instructions. For example: in the instruction SBC #14, SBC is the operator (it performs an operation) and #14 is the operand (it's an argument needed by the operator).
Oooh. Might be little challenging to remember it. "Operator Code" as "Opcode". But not sure about operand meaning.
the quantity on which an operation is to be done. Isn't that what Value means? Or Variable? Like "Find the Value in Equations"? Value tricks me many times.
Operands are whatever each instruction needs specified in order to do its job. It can be an immediate number, an address, a branch distance, an address where the processor looks up the final desired address, etc.. Some instructions' addressing mode is implied, so they have no operand; for example, SEC (SEt Carry flag) needs no operand, because the op code gives the processor all it needs to know. The one byte is enough. Others have a one-byte operand, and some have a two-byte operand. None have any more than two bytes of operand.
http://WilsonMinesCo.com/ lots of 6502 resources

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Sun Jun 14, 2020 2:54 pm

Garth wrote:
Sat Jun 13, 2020 9:11 pm
DocWaluigean wrote:
Sat Jun 13, 2020 5:23 pm
Garth wrote:
Sat Jun 13, 2020 4:59 pm
You cannot rotate, shift, or add in the X & Y registers, nor S. You can compare X or Y with CPX or CPY, and that can affect the C flag. You cannot compare S though.
This one, I'm a little confused... I'm thinking the X and Y Register will NOT be affected by Overflow Flag?
Unless I'm forgetting something, the only instructions that will be affected (passive) by the oVerflow flag V are BVS and BVC. Arithmetic functions that actively set or clear the V flag are ADC and SBC, and then V's meaning is relevant for signed numbers, which you don't need to get into yet. V does have a nice benefit with the BIT instruction too. None of these involve X or Y.

Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
Mostly right. Actions on A, X, or Y can set the N flag.

Okay, ONLY Register A can use ADC and SBC, got it.
Right.

This one brings me interesting questions. Let's say that Register A has Carry Flag turn on, Register X has Negative Flag turn on, and Register Y has Zero Flag turn on. Through most recent operations, will the flag turn off and on many times when I use certain Registers?

-I use the Register A. The Carry Flag is turned on.
-Then I use Register X, which has Negative Flag turned on.
[Either Carry Flag is also turn on because Register A is still carrying number? Or if it turns off because I'm using Register X right now.]
-Then I use the Register A.
[Does the Negative Flag still remains on at this point? Or NOW it turns off the Negative Flag but it turns ON the Carry Flag?]
Then I used the Register Y, which has Zero Flag turn on.
[Does it turns off both the Negative Flag and Carry Flag, but NOW turns on the Zero Flag?]
Then I used the Register X Flag.
[Does it turn off the Zero Flag, and turns off the Carry Flag, but NOW turns on the Negative Flag?]
The flags are in the Processor status register P, not in A, X, or Y. They reflect the last action that affects them, regardless of whether that action was on A, X, or Y. So A does not have a C flag. P does. X does not have an N flag. P does. Etc.. There is only one C flag, one N flag, one Z flag, etc., not one for each register.

Right. The stack pointer has a very specific purpose that's separate from what A, X, and Y are used for. As for switches, I'm not sure what you're asking.
I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
There is only one carry flag, and it's in the P register. There aren't separate ones in A, X, and Y. The C, N, Z, and V flags are used for conditional branch instructions to know whether to branch or not. These include BCC, BCS, BPL, BMI, BNE, BEQ, BVC, and BVS, respectively, for clear and set conditions.
Alright. I'll learn about V Flag later if it's not that important?

===
Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
Mostly right. Actions on A, X, or Y can set the N flag.

Does "Actions on A, X, or Y" ALSO applies to Carry Flag and Zero Flag? Or only one at a time?

===

Good to know. Register A is the most worker Register compare to X and Y [and S and PC]

===
The flags are in the Processor status register P, not in A, X, or Y. They reflect the last action that affects them, regardless of whether that action was on A, X, or Y. So A does not have a C flag. P does. X does not have an N flag. P does. Etc.. There is only one C flag, one N flag, one Z flag, etc., not one for each register.
Okay, now I got confused on that.....

===
Right. The stack pointer has a very specific purpose that's separate from what A, X, and Y are used for. As for switches, I'm not sure what you're asking.
I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
There is only one carry flag, and it's in the P register. There aren't separate ones in A, X, and Y. The C, N, Z, and V flags are used for conditional branch instructions to know whether to branch or not. These include BCC, BCS, BPL, BMI, BNE, BEQ, BVC, and BVS, respectively, for clear and set conditions.
[/quote]

So you can only have one Flag turn on at a time, I'm thinking?

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Sun Jun 14, 2020 2:55 pm

Garth wrote:
Sat Jun 13, 2020 9:21 pm
DocWaluigean wrote:
Sat Jun 13, 2020 7:08 pm
In this case you can simply say SBC/CMP subtracts a number from another, but if you want to get technical, numbers are specified as operands in instructions. For example: in the instruction SBC #14, SBC is the operator (it performs an operation) and #14 is the operand (it's an argument needed by the operator).
Oooh. Might be little challenging to remember it. "Operator Code" as "Opcode". But not sure about operand meaning.
the quantity on which an operation is to be done. Isn't that what Value means? Or Variable? Like "Find the Value in Equations"? Value tricks me many times.
Operands are whatever each instruction needs specified in order to do its job. It can be an immediate number, an address, a branch distance, an address where the processor looks up the final desired address, etc.. Some instructions' addressing mode is implied, so they have no operand; for example, SEC (SEt Carry flag) needs no operand, because the op code gives the processor all it needs to know. The one byte is enough. Others have a one-byte operand, and some have a two-byte operand. None have any more than two bytes of operand.
So Operands is the "Answer" or "Result"? Something that can easily mean it if I were younger.

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Sun Jun 14, 2020 5:29 pm

DocWaluigean wrote:
Sun Jun 14, 2020 2:54 pm
Garth wrote:
Sat Jun 13, 2020 9:11 pm
DocWaluigean wrote:
Sat Jun 13, 2020 5:23 pm
Okay, A, X, and Y can turn on the Negative Flag. But NOT S nor PC.
Mostly right. Actions on A, X, or Y can set the N flag.
Does "Actions on A, X, or Y" ALSO applies to Carry Flag and Zero Flag? Or only one at a time?
Yes, as I put later in the same post.

The flags are in the Processor status register P, not in A, X, or Y. They reflect the last action that affects them, regardless of whether that action was on A, X, or Y. So A does not have a C flag. P does. X does not have an N flag. P does. Etc.. There is only one C flag, one N flag, one Z flag, etc., not one for each register.
Okay, now I got confused on that.....
The status flags are all in P, which could also be called the flags register.

I mean Flags when I said switches. Like I can turn on all Carry Flags using 3 Registers.
There is only one carry flag, and it's in the P register. There aren't separate ones in A, X, and Y. The C, N, Z, and V flags are used for conditional branch instructions to know whether to branch or not. These include BCC, BCS, BPL, BMI, BNE, BEQ, BVC, and BVS, respectively, for clear and set conditions.
So you can only have one Flag turn on at a time, I'm thinking?
No; the flags are mostly independent of each other. If you start with C off and add $7F and $81 (which is $100), you'll get 0 which makes Z=1 but you'll also get C=1 to hold the 1 that got carried into the hundreds' place; so that's two flags set at the same time right there.

So Operands is the "Answer" or "Result"? Something that can easily mean it if I were younger.
No. Let's say you have a three-byte machine-language instruction. The first byte is the op code, and the next two bytes are the operand; but it's all one instruction. The results come when the instruction gets executed, not when it is written or assembled.
http://WilsonMinesCo.com/ lots of 6502 resources

User avatar
tokumaru
Posts: 11892
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Hello, I'm back, still need assistences

Post by tokumaru » Mon Jun 15, 2020 4:27 am

Operands are the things you need in order to carry out an operation. For example, if you're faced with the task of opening the door to your house, the operands are the keys and the door, the things without which you can't possibly finish the task.

In 6502 assembly, when the CPU is working and finds the "ADC" operator, it knows it needs to perform the addition of 2 numbers, and these 2 numbers must come from somewhere. These are the operands. The first number, as is written in the CPU's documentation, always comes from the accumulator, meaning it's implied (you don't have to explicitly reference it), and the other will be specified after the operator, and since it can come from different places (directly from the instruction, from an address in memory, etc.), the way in which it's written will make that clear (# means a value directly from the instruction, a number or label means an address in memory, and so on).

turboxray
Posts: 115
Joined: Thu Oct 31, 2019 12:56 am

Re: Hello, I'm back, still need assistences

Post by turboxray » Mon Jun 15, 2020 7:29 pm

DocWaluigean wrote:
Tue Jun 09, 2020 10:30 pm
There's a reason why I'm asking so many questions here. I can't understand well with explanations on books, on Easy6502, and famously Nerdy Nights. It's been two years since I learn what A X and Y Register is for, and I understand fully on those stuff. I'm not like anyone or you who could understand each sentences and details so well. If I do this by myself, I will always be lost on whatever I'm doing.
Just curious, but do you have any sort of programming background or is this all new to you???

I know assembly can't daunting to look at, at first, but broken down into basic instructions, the entry level stuff is pretty straight forward (talking about the basics). If you're truly committed to learning 65x, and some of this is a struggle, I strongly suggest writing small bits of code and stepping through it with an emulator + debugger.

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 510
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Re: Hello, I'm back, still need assistences

Post by Jarhmander » Tue Jun 16, 2020 8:18 am

I can't agree more with this. Programming is something you learn by doing it. It really helps when you have some environnement where you can freely experiment and do things that works or that crashes and burns — both are valuable experience. Back in college, I learned assembly (self-taught) on PIC microcontrollers because I could quickly program something and look if it worked right after.
((λ (x) (x x)) (λ (x) (x x)))

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Tue Jun 16, 2020 4:08 pm

turboxray wrote:
Mon Jun 15, 2020 7:29 pm
DocWaluigean wrote:
Tue Jun 09, 2020 10:30 pm
There's a reason why I'm asking so many questions here. I can't understand well with explanations on books, on Easy6502, and famously Nerdy Nights. It's been two years since I learn what A X and Y Register is for, and I understand fully on those stuff. I'm not like anyone or you who could understand each sentences and details so well. If I do this by myself, I will always be lost on whatever I'm doing.
Just curious, but do you have any sort of programming background or is this all new to you???

I know assembly can't daunting to look at, at first, but broken down into basic instructions, the entry level stuff is pretty straight forward (talking about the basics). If you're truly committed to learning 65x, and some of this is a struggle, I strongly suggest writing small bits of code and stepping through it with an emulator + debugger.
Jarhmander wrote:
Tue Jun 16, 2020 8:18 am
I can't agree more with this. Programming is something you learn by doing it. It really helps when you have some environnement where you can freely experiment and do things that works or that crashes and burns — both are valuable experience. Back in college, I learned assembly (self-taught) on PIC microcontrollers because I could quickly program something and look if it worked right after.
Yes I do, but it's very complicated to say.

I went on my first semester on C class in Gateway Technical College, and I struggle with most of the code, so I stayed in class majority of times to understand it.

Recently in late 2019, I made a game which is a Breakout clone using GameMaker Studio 2, which I already uploaded it here. The R changes direction at cost of score, left is left and right is right, and spacebar start the ball hitting.
DocWaluigean's Breakout.zip
(2.56 MiB) Downloaded 49 times
I even tried out SmileBASIC for Nintendo 3DS, and SmileBASIC 4 for the Switch. Needless to say, I understand the functions of "IF THEN", "variables and code" and other stuff. The 2-D Array and 3-D Array I understand how they do it. I also understand how they do the "DATA" "READ" partially.

The problem I'm dealing with is the forms of explanations where I couldn't grasp at details and information with just words. Just because I know how they use it doesn't mean I know how to demonstrate it through errors that I see correct, but incorrect to others. I learn more by seeing how they do it and how fun the coding is. And my grammar is very crooked to understand certain information about it.

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Tue Jun 16, 2020 4:11 pm

tokumaru wrote:
Mon Jun 15, 2020 4:27 am
Operands are the things you need in order to carry out an operation. For example, if you're faced with the task of opening the door to your house, the operands are the keys and the door, the things without which you can't possibly finish the task.

In 6502 assembly, when the CPU is working and finds the "ADC" operator, it knows it needs to perform the addition of 2 numbers, and these 2 numbers must come from somewhere. These are the operands. The first number, as is written in the CPU's documentation, always comes from the accumulator, meaning it's implied (you don't have to explicitly reference it), and the other will be specified after the operator, and since it can come from different places (directly from the instruction, from an address in memory, etc.), the way in which it's written will make that clear (# means a value directly from the instruction, a number or label means an address in memory, and so on).
"For example, if you're faced with the task of opening the door to your house, the operands are the keys and the door, the things without which you can't possibly finish the task."

That made so much sense about it, but curse my grammar.
So Operands are like... the "Actors" of existences that serves it's purpose. Their job is to act and do what they're task to do, which is operands? Or are they the "Carrier" of tasks like banker who carries money to provide or...?

I understand it, but I don't know how to word it to a possible child or poor-grammar people like me if I were teaching.

=====

"Operands are whatever each instruction needs specified in order to do its job."

It's really hard to think about it when I think. According to what you say about door and key, in my mind, "Operands" is a script and the "Operator" is the actor. Like child needing a chore list from mother to do it right?

Operands are "things you needed to do the job." , is that it??? Operator is "The job guy with the 'operands' items."
A chef, an operator, needs oven, an operands.
A plumber, operator, needs a plunger, operands.

If it's true, that's wonderful. I wonder what else term I need to learn within 6502 Developers.

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Tue Jun 16, 2020 7:03 pm

DocWaluigean wrote:
Tue Jun 16, 2020 4:11 pm
tokumaru wrote:
Mon Jun 15, 2020 4:27 am
Operands are the things you need in order to carry out an operation. For example, if you're faced with the task of opening the door to your house, the operands are the keys and the door, the things without which you can't possibly finish the task.
So Operands are like... the "Actors" of existences that serves its purpose. Their job is to act and do what they're task to do, which is operands? Or are they the "Carrier" of tasks like banker who carries money to provide or...?
There could be quite a few variations, depending on the addressing mode. One of the simplest might be direct, and an example would be if the op code tells you to open the door, and the operand tells you whether it's the front door, the closet door, the refrigerator door, etc..
http://WilsonMinesCo.com/ lots of 6502 resources

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Wed Jun 17, 2020 12:02 pm

Garth wrote:
Tue Jun 16, 2020 7:03 pm
DocWaluigean wrote:
Tue Jun 16, 2020 4:11 pm
tokumaru wrote:
Mon Jun 15, 2020 4:27 am
Operands are the things you need in order to carry out an operation. For example, if you're faced with the task of opening the door to your house, the operands are the keys and the door, the things without which you can't possibly finish the task.
So Operands are like... the "Actors" of existences that serves its purpose. Their job is to act and do what they're task to do, which is operands? Or are they the "Carrier" of tasks like banker who carries money to provide or...?
There could be quite a few variations, depending on the addressing mode. One of the simplest might be direct, and an example would be if the op code tells you to open the door, and the operand tells you whether it's the front door, the closet door, the refrigerator door, etc..
I'm wondering what you mean about "There could be quite a few variations, depending on the addressing mode."

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Wed Jun 17, 2020 1:58 pm

DocWaluigean wrote:
Wed Jun 17, 2020 12:02 pm
I'm wondering what you mean about "There could be quite a few variations, depending on the addressing mode."
In an effort to keep it simple (since you're just starting out), I'll give just one example, in the analogy of a treasure hunt, the game where you get a clue that tells you where to look for the next one, and so on, until you finally reach the treasure, and that is indirects. So let's say you have a JMP (foobar). The parentheses are telling you it's indirect. Rather than saying "Jump to label 'foobar'," it's saying, "Read variable 'foobar', and it will tell you what address to jump to." In the three-byte jump-indirect instruction, the op code is $6C, and the two-byte operand will give it the address of variable foobar.

There's also absolute, indexed, indexed indirect, indirect indexed, (the difference between the last two is whether the the indexing value is added before or after the indirection), and if you want to go further and get into self-modifying code (which requires that the code be in RAM), even double indirects, or even double indexing! This list is not exhaustive.
http://WilsonMinesCo.com/ lots of 6502 resources

DocWaluigean
Posts: 205
Joined: Sun Jun 17, 2018 6:41 pm

Re: Hello, I'm back, still need assistences

Post by DocWaluigean » Wed Jun 17, 2020 4:42 pm

Garth wrote:
Wed Jun 17, 2020 1:58 pm
DocWaluigean wrote:
Wed Jun 17, 2020 12:02 pm
I'm wondering what you mean about "There could be quite a few variations, depending on the addressing mode."
In an effort to keep it simple (since you're just starting out), I'll give just one example, in the analogy of a treasure hunt, the game where you get a clue that tells you where to look for the next one, and so on, until you finally reach the treasure, and that is indirects. So let's say you have a JMP (foobar). The parentheses are telling you it's indirect. Rather than saying "Jump to label 'foobar'," it's saying, "Read variable 'foobar', and it will tell you what address to jump to." In the three-byte jump-indirect instruction, the op code is $6C, and the two-byte operand will give it the address of variable foobar.

There's also absolute, indexed, indexed indirect, indirect indexed, (the difference between the last two is whether the the indexing value is added before or after the indirection), and if you want to go further and get into self-modifying code (which requires that the code be in RAM), even double indirects, or even double indexing! This list is not exhaustive.
Isn't "Indirect" the opposite of direct?

So the gameplay is indirect, or the story, or both?

three-byte jump-indirect instruction?

Can you give me 3 code examples on what you mean? Or is this trying to teach me the terms?

Let me re-read it again before this:
There could be quite a few variations, depending on the addressing mode.
A few variations as in Opcode, [The Variable? What's it called for this community?], and the Address?
One of the simplest might be direct, and an example would be if the op code tells you to open the door, and the operand tells you whether it's the front door, the closet door, the refrigerator door, etc..
It's really hard to understand and say the word at same time. Opcode [JMP] Tells you to open a door, and the Operand [Address locations] would be different door, like refrigerator and stuff.

Address $0100 is normal door
Address $0200 is the refrigerator door
Address $0300 is the closet door
Address $0400 is the other door not specified [maybe car door]

That's what you mean?
Operand is the Address, and Operator is the Opcode/number system?

Garth
Posts: 195
Joined: Wed Nov 30, 2016 4:45 pm
Location: Southern California
Contact:

Re: Hello, I'm back, still need assistences

Post by Garth » Wed Jun 17, 2020 5:59 pm

Chapter 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.
http://WilsonMinesCo.com/ lots of 6502 resources

Post Reply