It is currently Tue Nov 20, 2018 6:12 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 343 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 23  Next
Author Message
PostPosted: Sun Sep 09, 2018 8:09 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1251
Bingo! Or, more or less bingo. That BRK doesn't come from nowhere, though.

So the first time you run it, it's actually an LDA #$?? opcode, not LDX #$??. It starts with
$A9 $A2. LDA #$A2
And this is why at the end A has $A2 in it.

Then it stores that to $A2 to $0600. And, remember, that's where the first instruction is! So we overwrite the opcode for LDA #$?? with the opcode for LDX #$??. (Which is $A2).

When we reset, it means the PC will start again at the instruction at $0600. But it just got changed!

So the second time you run it, it starts with:
$A2 $A2. LDX #$A2.
And this is why at the end of second run, X (instead of A) has $A2 in it.

But there's still an sta $0600 rather than stx $0600. On easy6502, A starts with $00 in it.

So once again, the first instruction gets changed to a different one. ($00). And when you reset, you get BRK. That's the part you noticed.

This was a long way to get to this point, I admit. But does this make sense? The 6502 can see the addresses from $0000 to $FFFF. It can attempt to read from, attempt to write to, or attempt to execute (run the opcode at) any of those addresses. You have learned 3 ways to attempt a read from an address. lda $????, ldx $???? and ldy $????. And you have learned 3 ways to attempt to write to an address. sta $????, stx $????, sty $????. And, if you understand the above, you understand how an address is "executed". That is, how it looks up the opcode at that address, and does the action associated with that opcode then arrives at (sets the PC to) the address of the next instruction.

It does not care what "type" of address it is in any of those cases. It doesn't care if it's RAM. It doesn't care if it's a register. It doesn't check if the write will even have an effect. (It will always ATTEMPT to write, but the value that was attempted to be written is not necessarily stored, depending on the address.) In this example, you wrote to an address "meant for" code, but the 6502 doesn't care what an address is"meant for". You can also read addresses "meant for" code, and you can execute addresses "meant for" variables. The 6502 does not care about what any given address is "meant for".

Does any of that not make sense? It is vitally important that especially the last two paragraphs make sense.

Edit: It was not meant to be purposefully difficult, though I do realize it IS/WAS difficult. I was running out of ways to make addresses clear which I still believe to be a large part of your confusion. The 6502 considers all addresses to be the same type of thing (with arguably two exceptions we'll cover later), regardless of whether its reading from, or writing to, or executing that address. They're different for the programmer, that's why a memory map exists. For the programmer. The 6502 itself is basically unconcerned by the memory map.

If we're all clear here, I'll test your knowledge of the PC/labels. And then we'll get back to branching.

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 9:15 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
Bingo! Or, more or less bingo. That BRK doesn't come from nowhere, though.

So the first time you run it, it's actually an LDA #$?? opcode, not LDX #$??. It starts with
$A9 $A2. LDA #$A2
And this is why at the end A has $A2 in it.

Then it stores that to $A2 to $0600. And, remember, that's where the first instruction is! So we overwrite the opcode for LDA #$?? with the opcode for LDX #$??. (Which is $A2).

When we reset, it means the PC will start again at the instruction at $0600. But it just got changed!

So the second time you run it, it starts with:
$A2 $A2. LDX #$A2.
And this is why at the end of second run, X (instead of A) has $A2 in it.

But there's still an sta $0600 rather than stx $0600. On easy6502, A starts with $00 in it.

So once again, the first instruction gets changed to a different one. ($00). And when you reset, you get BRK. That's the part you noticed.

This was a long way to get to this point, I admit. But does this make sense? The 6502 can see the addresses from $0000 to $FFFF. It can attempt to read from, attempt to write to, or attempt to execute (run the opcode at) any of those addresses. You have learned 3 ways to attempt a read from an address. lda $????, ldx $???? and ldy $????. And you have learned 3 ways to attempt to write to an address. sta $????, stx $????, sty $????. And, if you understand the above, you understand how an address is "executed". That is, how it looks up the opcode at that address, and does the action associated with that opcode then arrives at (sets the PC to) the address of the next instruction.

It does not care what "type" of address it is in any of those cases. It doesn't care if it's RAM. It doesn't care if it's a register. It doesn't check if the write will even have an effect. (It will always ATTEMPT to write, but the value that was attempted to be written is not necessarily stored, depending on the address.) In this example, you wrote to an address "meant for" code, but the 6502 doesn't care what an address is"meant for". You can also read addresses "meant for" code, and you can execute addresses "meant for" variables. The 6502 does not care about what any given address is "meant for".

Does any of that not make sense? It is vitally important that especially the last two paragraphs make sense.

Edit: It was not meant to be purposefully difficult, though I do realize it IS/WAS difficult. I was running out of ways to make addresses clear which I still believe to be a large part of your confusion. The 6502 considers all addresses to be the same type of thing (with arguably two exceptions we'll cover later), regardless of whether its reading from, or writing to, or executing that address. They're different for the programmer, that's why a memory map exists. For the programmer. The 6502 itself is basically unconcerned by the memory map.

If we're all clear here, I'll test your knowledge of the PC/labels. And then we'll get back to branching.


This information is literally illogical to me, I'm starting to feel really upset or really mad at myself since the Easy6502/Nerdy Night issues again..and I do not qualify to complain about this...
Quote:
So the first time you run it, it's actually an LDA #$?? opcode, not LDX #$??. It starts with
$A9 $A2. LDA #$A2
And this is why at the end A has $A2 in it.


Okay, I understand that. Needs better wording on the last sentences though. "At the end, [the A Register] has $A2 in it."

Quote:
Then it stores that to $A2 to $0600. And, remember, that's where the first instruction is! So we overwrite the opcode for LDA #$?? with the opcode for LDX #$??. (Which is $A2).

When we reset, it means the PC will start again at the instruction at $0600. But it just got changed!


What do you mean? or why? You didn't told me we had to re-write or replace LDA with LDX.
Quote:
So the second time you run it, it starts with:
$A2 $A2. LDX #$A2.
And this is why at the end of second run, X (instead of A) has $A2 in it.

But there's still an sta $0600 rather than stx $0600. On easy6502, A starts with $00 in it.

So once again, the first instruction gets changed to a different one. ($00). And when you reset, you get BRK. That's the part you noticed.


There is a LOT of questions I'm literally missing. I don't see LDA turned into LDX alongside with BRK. Or you never told me I need to disassemble...

Quote:
This was a long way to get to this point, I admit. But does this make sense? The 6502 can see the addresses from $0000 to $FFFF. It can attempt to read from, attempt to write to, or attempt to execute (run the opcode at) any of those addresses. You have learned 3 ways to attempt a read from an address. lda $????, ldx $???? and ldy $????. And you have learned 3 ways to attempt to write to an address. sta $????, stx $????, sty $????. And, if you understand the above, you understand how an address is "executed". That is, how it looks up the opcode at that address, and does the action associated with that opcode then arrives at (sets the PC to) the address of the next instruction.


No, it does not. Okay, $0000 - FFFF, I understand. and then read, write to, or excecute. Okay LDA/X/Y. But I'm still not understanding to your certain questions.


Quote:
Edit: It was not meant to be purposefully difficult, though I do realize it IS/WAS difficult. I was running out of ways to make addresses clear which I still believe to be a large part of your confusion. The 6502 considers all addresses to be the same type of thing (with arguably two exceptions we'll cover later), regardless of whether its reading from, or writing to, or executing that address. They're different for the programmer, that's why a memory map exists. For the programmer. The 6502 itself is basically unconcerned by the memory map.

If we're all clear here, I'll test your knowledge of the PC/labels. And then we'll get back to branching.



Let's try do a drawing of examples of how Branching works. So I can get the idea if we're on the same page. I need one-by-one step for it...

Edit: I don't want to put emotions in here. But I am NOT and NEVER giving up. I am never going to wait another 5 years to learn the same program that I struggled 5 years ago just for confusion about A X Y Register.


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 9:46 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1251
Quote:
What do you mean? or why? You didn't told me we had to re-write or replace LDA with LDX.

I didn't tell you you had to replace LDA with LDX because you didn't have to do that. The code did it to itself.

I told you that in easy6502, your code starts at address $0600. This means the first opcode of the first instruction is at $0600. The code I gave you writes to $0600 which changes what the first instruction is. Does that make sense?
Quote:
Or you never told me I need to disassemble...

You didn't need to disassemble, but I'm very glad you found that resource without me directing you to it. What I was hoping for is that you'd make the connection that since your code starts at $0600 and the program writes to $0600, that that might change the code. I left a bunch of hints about it in the post.

Anyway. Does it make sense now? Even if not, I guess I'm cool with it so long as you understand about how 6502 deals with addresses. Not every example is gonna land. If you wanna get back to branching, give me the address of all of these instructions, and tell me how you found those addresses. Edit: I guess I should say, assume the first one starts at $0600.
Code:
lda #$00
sta $0201
tay
lda $0200

Knowing the purpose of the PC should help.

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 9:55 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
Quote:
What do you mean? or why? You didn't told me we had to re-write or replace LDA with LDX.

I didn't tell you you had to replace LDA with LDX because you didn't have to do that. The code did it to itself.

I told you that in easy6502, your code starts at address $0600. This means the first opcode of the first instruction is at $0600. The code I gave you writes to $0600 which changes what the first instruction is. Does that make sense?
Quote:
Or you never told me I need to disassemble...

You didn't need to disassemble, but I'm very glad you found that resource without me directing you to it. What I was hoping for is that you'd make the connection that since your code starts at $0600 and the program writes to $0600, that that might change the code. I left a bunch of hints about it in the post.

Anyway. Does it make sense now? Even if not, I guess I'm cool with it. Not every example is gonna land. If you wanna get back to branching, give me the address of all of these instructions, and tell me how you found those addresses.
Code:
lda #$00
sta $0201
tay
lda $0200

Knowing the purpose of the PC should help.


If I want to know everything, I can't risk skipping branching..........I told a lot to myself about how bad and/or difficult the 6502 lectures could be...and I do not want to fail and lie to myself that I ignore and refuse to help and skip... Would I even respect myself if I skip even tiny lessons about it after I said how I keep struggling to learn? it happens to everyone on everything in any time, and the potentials become decayed or destroyed. I do never want it happen to here...
I am not racist, yet potentially, I could be delusional, but if the whole people in Japan accept skipping and refusal to keep going and understanding even tiniest problems, what qualities of life and inventions would we be missing out, or worse, never come true?

Is there another example about branching................?


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 10:12 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1251
Just to note something: From now on, I'm going to be writing way less. I'm gonna take advantage of the format of having you reply. Why risk writing a long document when I can just write parts at a time and immediately course correct for understanding?

So, remember that literally all the Program Counter does is keep track of the address of the next instruction to run. The "Step" button in easy6502 runs exactly one instruction. With these two pieces of knowledge, that assignment should be complete-able.

(Seriously, though, does how the code ends up getting changed make sense after the post you just quoted? "No," is an acceptable answer but I did ask because I actually wanted to know.)

Quote:
Is there another example about branching................?

Probably not! I'll probably give you the old examples and the old assignments again once I'm sure you understand about the PC and labels. We're not skipping branching. We're handling the prerequisite knowledge for branching.

_________________
https://kasumi.itch.io/indivisible


Last edited by Kasumi on Sun Sep 09, 2018 10:23 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 10:23 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
Just to note something: From now on, I'm going to be writing way less. I'm gonna take advantage of the format of having you reply. Why risk writing a long document when I can just write parts at a time and immediately course correct for understanding?

So, remember that literally all the Program Counter does it keep track of the address of the next instruction to run. The "Step" button in easy6502 runs exactly one instruction. With these two pieces of knowledge, that assignment should be complete-able.

(Seriously, though, does how the code ends up getting changed make sense after the post you just quoted? "No," is an acceptable answer but I did ask because I actually wanted to know.)

Quote:
Is there another example about branching................?

Probably not! I'll probably give you the old examples and the old assignments again once I'm sure you understand about the PC and labels. We're not skipping branching. We're handling the prerequisite knowledge for branching.


No on the code changed making sense...

I don't like change, but we'll see if this less-write format would help more effectively than long-write like before.

Maybe I have to start drawing and show-and-tell to give examples of what I think or HOW it works. Like the quote I show:

Attachment:
83687ea12f0290b392644e7ae37d1b8a.jpg
83687ea12f0290b392644e7ae37d1b8a.jpg [ 93.68 KiB | Viewed 1244 times ]


Attachment:
index.jpg
index.jpg [ 7.34 KiB | Viewed 1244 times ]


...not sure if off-topic, but this would help encourage me to try to do different explanation in the future...


Top
 Profile  
 
PostPosted: Mon Sep 10, 2018 1:50 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 940
Location: cypress, texas
DocWaluigean wrote:
unregistered wrote:
Kasumi wrote:
You can see how long each version of each instruction will be in the documentation: http://www.obelisk.me.uk/6502/reference.html#LDA
DocWaluigean, if you are scared by that site's design cause of its all-text-and-thin-table-lines ilk, than you share that fear with me. After finding the creator of the 6502 (MOS Technology)'s 6502 programming manual and printing out its Appendices it made finding the length of each instruction more fun for me.


starting at pdf page 204, I think, is where the MOS Technology helpful, to me at least, info starts. :)


That's very kind, Unregistered. But It's more of how awfully dull it looks. There is no legend or meaning when looking through it. It's like looking at a map of California, but there's no bus, restaurant, city, etc. It's no soul or heart into trying to teach everyone who DEEPLY want to learn how to program 6502.
I mean sure, this IS advanced, and it's expected to give a sense of "low point of motivations" where 99% of beginners decide to quit, and stuff. But I don't ever want to be like those.

If I were to read it again, I maaay give different replies, but I don't ever want to offend anyone. :oops:
You aren't offending me. :) There is a "legend" of sorts on page 204. It describes the meanings of each of the characters/symbols used in that Appendix. Obviously, it's not a detailed explanation; but, it was enough to make me have fun learning how to use that Appendix. When Kasumi, or someone else, talks about the high bytes, for instance, it was really fun and helpful for me to go to page 204, read the line where MOS Technology gives a symbol for "high byte", and then look through that Appendix to see how MOS Technology uses that symbol. It's not instantly useable, but the journey learning how that Appendix works was very fun for me. :) And, it's a super helpful Appendix so I recommend it to you.

p.s. I didn't mention that the inclusion of lots of whitespace by MOS Technology is what makes their Appendix much better, for me, than the link Kasumi provided.


Top
 Profile  
 
PostPosted: Mon Sep 10, 2018 6:07 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
unregistered wrote:
You aren't offending me. :) There is a "legend" of sorts on page 204. It describes the meanings of each of the characters/symbols used in that Appendix. Obviously, it's not a detailed explanation; but, it was enough to make me have fun learning how to use that Appendix. When Kasumi, or someone else, talks about the high bytes, for instance, it was really fun and helpful for me to go to page 204, read the line where MOS Technology gives a symbol for "high byte", and then look through that Appendix to see how MOS Technology uses that symbol. It's not instantly useable, but the journey learning how that Appendix works was very fun for me. :) And, it's a super helpful Appendix so I recommend it to you.

p.s. I didn't mention that the inclusion of lots of whitespace by MOS Technology is what makes their Appendix much better, for me, than the link Kasumi provided.


Hmmm... you may have a point... but remember that I don't know completely on 6502 Assembly.

Also, reading an old code from decades past, on the timeline where C++ rules all just feels like insult and waste of time... I admit it's my ignorances about the fact that even people like you can read more better and more concentrated than I am, but like I said earlier, the fact that I understood BASIC, C# increasingly, Java, yet I can't understand 6502, just means something is wrong with lectures before I came here, and something is wrong with myself, Unregistered.

So soon for the lesson, I'll try to draw as alternative of my answers or explanations if I couldn't explain well about it. Thanks for the MOS guideline, though!


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 11:49 am 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
(Cough cough?)


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 1:35 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1251
I gave an assignment. You did not complete, nor ask questions about the assignment. What should I say?

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 3:58 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
I gave an assignment. You did not complete, nor ask questions about the assignment. What should I say?

Wait what??? The assignment??? Where was it???

Kasumi wrote:
Just to note something: From now on, I'm going to be writing way less. I'm gonna take advantage of the format of having you reply. Why risk writing a long document when I can just write parts at a time and immediately course correct for understanding?

So, remember that literally all the Program Counter does is keep track of the address of the next instruction to run. The "Step" button in easy6502 runs exactly one instruction. With these two pieces of knowledge, that assignment should be complete-able.

(Seriously, though, does how the code ends up getting changed make sense after the post you just quoted? "No," is an acceptable answer but I did ask because I actually wanted to know.)

Quote:
Is there another example about branching................?

Probably not! I'll probably give you the old examples and the old assignments again once I'm sure you understand about the PC and labels. We're not skipping branching. We're handling the prerequisite knowledge for branching.


This was the last reply. I didn't see any assignment? :?: :?: :?: :?: :?: I thought you were making a big assignment for days about the next one?????


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 4:01 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
Quote:
What do you mean? or why? You didn't told me we had to re-write or replace LDA with LDX.

I didn't tell you you had to replace LDA with LDX because you didn't have to do that. The code did it to itself.

I told you that in easy6502, your code starts at address $0600. This means the first opcode of the first instruction is at $0600. The code I gave you writes to $0600 which changes what the first instruction is. Does that make sense?
Quote:
Or you never told me I need to disassemble...

You didn't need to disassemble, but I'm very glad you found that resource without me directing you to it. What I was hoping for is that you'd make the connection that since your code starts at $0600 and the program writes to $0600, that that might change the code. I left a bunch of hints about it in the post.

Anyway. Does it make sense now? Even if not, I guess I'm cool with it so long as you understand about how 6502 deals with addresses. Not every example is gonna land. If you wanna get back to branching, give me the address of all of these instructions, and tell me how you found those addresses. Edit: I guess I should say, assume the first one starts at $0600.
Code:
lda #$00
sta $0201
tay
lda $0200

Knowing the purpose of the PC should help.


THIS is the assignment?? I thought it was overview of what we learned while you said bingo??? :?: :?:

There is a poor or big miscommunications here, and I'm lost right now.


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 4:40 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1251
It says, "Give me the address of all these instructions, and tell me how you found these addresses." How could it be overview?

_________________
https://kasumi.itch.io/indivisible


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 4:53 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
Kasumi wrote:
It says, "Give me the address of all these instructions, and tell me how you found these addresses." How could it be overview?


If you have the same mindset as me, you'd understand about my random or unknown explanations and emotions. T-T And you'd understand struggling in life in my shoes, even forgetting it...

---

I'll see about all instructions you mentioned with address.


Top
 Profile  
 
PostPosted: Tue Sep 11, 2018 6:09 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 150
; PC=$0600

lda #$00 ; Put number 0 into Register A.

; PC=$0602

sta $0201 ; Place number 0 into Address Code $0201.

; PC=$0605

tay ; Copy-and-Paste number 0 from Register A into Register Y.

; PC=$0606

lda $0200 ; Put numbers contained inside Address Code $0200 into Register A. [WRONG!?]

; PC=$0609


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 343 posts ]  Go to page Previous  1 ... 14, 15, 16, 17, 18, 19, 20 ... 23  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group