It is currently Sat Sep 22, 2018 12:38 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 273 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19  Next
Author Message
PostPosted: Sat Sep 08, 2018 12:26 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
The Branch Post wrote:
The PC is the Program Counter. It keeps track of the address of the next instruction the CPU will execute.

Quote:
DocWaluigean wrote:
So it IS "The Address you are on now!" Is it?

Yes. The post says that right away.

DocWaluigean wrote:
***Using Easy6502: So the Program Counter is actually memory containment?

I introduced the concept with a one sentence introduction of it. You asked for clarification, and I gave it. And then you came up with an entirely different explanation of it. Can you understand how this might be confusing to me? It makes it hard to keep track of what you have actually learned.
Edit: Or here:
DocWaluigean wrote:
you basically never give any thought to the Program Counter. (Or at least, I don't!)
So all this reading for nothing???

the post wrote:
I teach you about it now, so that you can better track the branching examples.


So let's try something different.

The 6502 can "see" (has immediate access to) 65536 "addresses". They occupy $0000-$FFFF. For purposes of this lesson, all the addresses can be read from (lda $????) or written to (sta $????). All addresses are a "home" for a single byte. The address is where to find that byte.

When you click "Assemble" in easy6502, your code is turned into bytes and placed starting at $0600. That is to say that the address or "home" of the first byte of the first instruction that you type will be $0600. That's where to find it.

Is there anything here that is not clear?

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


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 3:02 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
Kasumi wrote:
The Branch Post wrote:
The PC is the Program Counter. It keeps track of the address of the next instruction the CPU will execute.

Quote:
DocWaluigean wrote:
So it IS "The Address you are on now!" Is it?

Yes. The post says that right away.

DocWaluigean wrote:
***Using Easy6502: So the Program Counter is actually memory containment?

I introduced the concept with a one sentence introduction of it. You asked for clarification, and I gave it. And then you came up with an entirely different explanation of it. Can you understand how this might be confusing to me? It makes it hard to keep track of what you have actually learned.
Edit: Or here:
DocWaluigean wrote:
you basically never give any thought to the Program Counter. (Or at least, I don't!)
So all this reading for nothing???

the post wrote:
I teach you about it now, so that you can better track the branching examples.


So let's try something different.

The 6502 can "see" (has immediate access to) 65536 "addresses". They occupy $0000-$FFFF. For purposes of this lesson, all the addresses can be read from (lda $????) or written to (sta $????). All addresses are a "home" for a single byte. The address is where to find that byte.

When you click "Assemble" in easy6502, your code is turned into bytes and placed starting at $0600. That is to say that the address or "home" of the first byte of the first instruction that you type will be $0600. That's where to find it.

Is there anything here that is not clear?


I have aaabsolutely no idea what your saying with the quotes. o-o Well... tiny bit if I read it again.

-I'm guessing I'm right about the lesson on Branching is "The Program Counter is where are you in Address now."

-When the Program Counter is going up, the Opcode goes up by 2, and the Address goes up by 3. When it's number/HEX/Decimals, it's only 2 code upward, in favor for the opcode, that's used in the Address code, and the number that's also used for the Address code. I'm guessing high-byte and low-byte doesn't count here.

-While for Address, it goes up by 3 because of Opcode being used, and Address code's high-byte and low-byte. Because of $12 and the $34 represent $1234, THAT's why it goes up by 3. They work differently. Because the $12 represent the "street" of the code, while $34 represent the "house of the code. $12 might be CPU, PPU, RAM. And the $34 might be the lever or role/job for what they do FOR CPU, PPU, RAM.

-Labels are a type of BIG box you can use for later codings.

-It's like writing a paper or note, where PC Opcode is a pen, while PC Address is a BOLD pen.

-----------
Code:
restart:
; $0600
ldx #$00 ;Put number 0 into X Register.  Use up 2 bytes; $0602.
inx ; Increase X Register by one. Resulting X=1 The ALREADY-USED opcode is not using up in the Address Code because it's already in there. Still one code = one waste.

;$0603

beq restart ;@GOTO restart, do the same thing, then go back to here. Used up 2 bytes for 2 code-lines.

;$0605

dex ; Decrese X Register by one, resulting X=0. The ALREADY-USED opcode is not using up in the Address Code because it's already in there. Still one code = one waste.

;$0606

bne restart ; @GOTO restart, repeat the same thing but after finish, go back to here instead of the first BNE. Same thing, used up 2 bytes for 2 code-lines.

;$0608

;-------

beq skip ; If the Zero Flag is turned on, or "Set", then @GOTO "skip" label. If the Zero Flag is turned OFF, then proceed on the coding lines.


lda #$00 ; Put 0 into Register A.
beq restart ; Repeat the entire same process, but this time, Register A is on the whole time.
skip: ; Go to this code if the Zero Flag is turned on. As one by one line goes through, it wast so many bytes.

;$060E

;Apparently ONLY Register A can give commands to Branch of BEQ and BNE.


---

Quote:
So let's try something different.

The 6502 can "see" (has immediate access to) 65536 "addresses". They occupy $0000-$FFFF. For purposes of this lesson, all the addresses can be read from (lda $????) or written to (sta $????). All addresses are a "home" for a single byte. The address is where to find that byte.

When you click "Assemble" in easy6502, your code is turned into bytes and placed starting at $0600. That is to say that the address or "home" of the first byte of the first instruction that you type will be $0600. That's where to find it.

Is there anything here that is not clear?


I guess it's all clear for a while? A little permanent marker but clean enough.

EDIT: by the way, if you sound a little bit upset, I'm sorry.


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 3:30 pm 
Offline
User avatar

Joined: Sat Feb 12, 2005 9:43 pm
Posts: 10814
Location: Rio de Janeiro - Brazil
DocWaluigean wrote:
THIRD TIME! Third time is a lucky number time. I'm going to read it, and I'm going to pretend that you never wrote this, so I can get it out of my system.

Just wanted to make it clear that I wasn't trying to be rude or anything, I was just warning you to be careful with your expectations. Programming games isn't always fun, most of it is actually solving problems. If you don't find problem-solving fun, programming games will always feel like a chore to you.


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 3:54 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
tokumaru wrote:
DocWaluigean wrote:
THIRD TIME! Third time is a lucky number time. I'm going to read it, and I'm going to pretend that you never wrote this, so I can get it out of my system.

Just wanted to make it clear that I wasn't trying to be rude or anything, I was just warning you to be careful with your expectations. Programming games isn't always fun, most of it is actually solving problems. If you don't find problem-solving fun, programming games will always feel like a chore to you.


Actually, that was a fun-sentences like if cartoony people were to say, "Welp! Third time's the charm!" It's more of "I'm starting to feel little more comfortable, I guess I should say it." attitude.

I'm sorry if I'm being the one whose rude though. It's, sadly, just who I am. Alongside I said earlier that it took me 5 years from beginning to learning all the way to last month to try to really learn 6502.

Also, I don't want to be view as, "This thug is up to something bad." this and other that. Obviously the internet is like the real world with illegal crimes and stuff. I'm not anything like those.


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 4:53 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
Quote:
-I'm guessing I'm right about the lesson on Branching is "The Program Counter is where are you in Address now."

This is correct. Or at least. It's correct that the program counter is where the CPU will next execute an instruction. You are not correct that that was the goal of the lesson. The Program Counter was taught only to make it easier to follow the real lesson, which was branching.
Quote:
-When the Program Counter is going up, the Opcode goes up by 2, and the Address goes up by 3. When it's number/HEX/Decimals, it's only 2 code upward, in favor for the opcode, that's used in the Address code, and the number that's also used for the Address code. I'm guessing high-byte and low-byte doesn't count here.

This is not. Each instruction always has an opcode. This is one byte. Most instructions then have an operand of either 1 or 2 bytes. So if you are using an instruction that is dealing with an address (that isn't $0000-$00FF) it is three bytes. One byte for the opcode. Two bytes for the operand which is an address.

Some instructions are exactly one byte total (just the opcode), we just haven't covered any of those yet.
Way simpler: The CPU just "knows" how many bytes each instruction is. It will add the size in bytes of the current instruction to the PC and then the PC will have the address of the next instruction.
Edit:
Quote:
Because the $12 represent the "street" of the code, while $34 represent the "house of the code. $12 might be CPU, PPU, RAM. And the $34 might be the lever or role/job for what they do FOR CPU, PPU, RAM.

This is actually a reasonably solid way to look at it. It is correct that the byte in $12's place usually does defines a "profession" (like construction), while the byte in $34's place usually chooses the role within that profession. (Flag Man, cement truck driver.) RAM isn't really delegated into jobs, though.
Quote:
-Labels are a type of BIG box you can use for later codings.

They're actually more like the label you put ON the box. Labels don't really "store" anything. They just name things.

How you've commented the example isn't correct, but I'm going another way for now.

Everyone following this topic will probably think I'm crazy for even trying this example here, but I think it will actually help.

I will explain why I'm doing this upfront. I want to make it clear that everything is just bytes. That the 6502 CPU doesn't care that much about things. Most context is created to help the programmer.

Order is VERY IMPORTANT. Do these things step by step. If you do anything out of order, you will need to navigate to the page again and follow the steps again starting from 1.

1. Go to an easy6502 code box.
2. Erase what's in the box.
3. Type (but don't assemble) the following code.
Code:
lda #$A2
sta $0600

This address should look familiar. It is the address of the first byte of the first instruction, if you recall.
4. Type 0600 next to Start: $
5. Check the checkbox next to "Monitor"
Your easy6502 box should now look like this:
Image
6. Click assemble
7. Check the checkbox next to "Debugger"
8. Click step.
9. Type out (in notepad or something, not easy6502) the values to the right of 0600: under the monitor checkbox. These are the bytes that the code (lda #$A2, sta $0600) became.
10. Click run.
11. Type out which values are in in A, X and Y underneath the bytes you typed out earlier.
12. In your document, type out the values to the right of 0600: under the monitor again. They've changed, but this should make sense. After all, you just stored a number there.
13. Click reset.
14. Click run.
15. Type out which values are in A, X, and Y underneath the bytes you typed out earlier.

What changed? Do you have a guess as to why this might be?

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


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 9:07 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
Code:
A=$00 X=$00 Y=$00
SP=$ff PC=$0600
NV-BDIZC
00110000

-
0600: a9 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

=====

run

=====

A=$00 X=$a2 Y=$00
SP=$ff PC=$0606
NV-BDIZC
10110000

-

0600: 00 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

=====

2nd run

=====

A=$00 X=$00 Y=$00
SP=$ff PC=$0601
NV-BDIZC
00110000

-

0600: 00 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Top
 Profile  
 
PostPosted: Sat Sep 08, 2018 9:35 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
You only need the values immediately to the right of 0600. Not below. (i.e .not the 0610, 0620 etc columns which are all zero.)

Something tells me the steps weren't followed exactly. The PC would not be $0600 at any of the points where you were meant to note what A, X and Y were, so your first run's value seem to be after either reset or assemble, not after run or step.

Your second run's results are also not what I want to show. You need to start entirely over with the steps if any mistake is made during them.

Also important: You are getting the values from A, X and Y and the values to the right of $0600 at DIFFERENT times, this is why they are not together in the steps.

You have the state of A, X and Y (step 11) before the values to the right of 0600 (step 9)

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


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 12:07 am 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
Kasumi wrote:
You only need the values immediately to the right of 0600. Not below. (i.e .not the 0610, 0620 etc columns which are all zero.)

Something tells me the steps weren't followed exactly. The PC would not be $0600 at any of the points where you were meant to note what A, X and Y were, so your first run's value seem to be after either reset or assemble, not after run or step.

Your second run's results are also not what I want to show. You need to start entirely over with the steps if any mistake is made during them.

Also important: You are getting the values from A, X and Y and the values to the right of $0600 at DIFFERENT times, this is why they are not together in the steps.

You have the state of A, X and Y (step 11) before the values to the right of 0600 (step 9)


6. Click assemble

Code:
0600: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Preprocessing ...
Indexing labels ...
Found 0 labels.
Assembling code ...
Code assembled successfully, 5 bytes.

A=$00 X=$00 Y=$00
SP=$ff PC=$0600
NV-BDIZC
00110000

=================

8. Click step.
9. Type out (in notepad or something, not easy6502) the values to the right of 0600: under the monitor checkbox. These are the bytes that the code (lda #$A2, sta $0600) became.


A=$a2 X=$00 Y=$00
SP=$ff PC=$0602
NV-BDIZC
10110000

Code:
0600: a9 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


Preprocessing ...
Indexing labels ...
Found 0 labels.
Assembling code ...
Code assembled successfully, 5 bytes.

=====

10. Click run.

A=$00 X=$8d Y=$00
SP=$ff PC=$0604
NV-BDIZC
10110000

0600: a2 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


=====

13. Click reset.
14. Click run.


A=$a2 X=$00 Y=$00
SP=$ff PC=$0606
NV-BDIZC
10110000

Code:
0600: a2 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
0610: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0620: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0630: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0640: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0650: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0660: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0670: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
06f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00


While re-reading it, I keep seeing missing info.

Instead of, "Below the box where you put the code, there's Monitor, Start, and Length. Type 0600 next to "Start: $"

It's "4. Type 0600 next to Start: $" .....

I'm really trying this time..


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 2:15 am 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
It's true I could have been more specific about where to type 0600, but there is an image very shortly after that shows what it should look like when the steps are completed. Even if there were not, there is only one place with text that says "Start: $" and only one place you can type into next to it.

This has come up a bit, and I promise I'm not trying to pick on you. But sometimes the key to understanding something is very shortly after the part you don't understand. If you always stop immediately on the first confusing thing, you may end up stuck when the answer was actually really close. For things like steps, it's often helpful to read all the steps once before actually doing any of them.

We are still getting different results, which is also strange. I'm not going to have you do it again, but just out of curiosity what's your browser/OS?

Here's what I get for step 9:
0600: a9 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
I click run, and for step 11 I get:
A=$a2 X=$00 Y=$00
And for 12 I get:
0600: a2 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00
I click reset, and run, and for step 15 I get:
A=$00 X=$a2 Y=$00

The only way I can get $8d into X is to reset and run multiple times instead of just once. But again, I won't have you do it again. These are my results. And the context for these results is the following. You assemble the program.
Code:
lda #$A2
sta $0600

The program becomes these bytes starting at address $0600:
Code:
0600: a9 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00

Some of them should look familiar. For instance, the a2 is from the lda #$A2 in the code that was assembled. And the 00 and 06 are from the sta $0600 in the code that was assembled. (The bytes are "backwards", yes. That is simply how the 6502 CPU stores addresses.)
This means $a9 is the opcode for LDA #??.
Because lda #?? needs another byte for the value (which is its operand), this means the next byte will be used to fill in the ?s. The next byte is $A2. Altogether, that's lda #$A2. Exactly what was typed in.

The 6502 completes that instruction and is now at the next instruction. The byte following the last byte of the last instuction (which was $A2) is the opcode of the next instruction.
This means $8d is the opcode for STA $????.
Because sta $???? needs TWO bytes for the address (which is its operand), this means the next two bytes will be used to fill in the ?s. The next two bytes are $00 and $06. Since 6502 stores them flipped, if you flip them back you get $0600. Altogether, that's sta $0600. Exactly what was typed in.

After the program is run, you get these values in A, X and Y.
Code:
A=$a2 X=$00 Y=$00

This should make sense, because there is an LDA #$A2 as the first instruction in the code. Now the bytes starting at address $0600 look like this:
Code:
0600: a2 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00

This should also make sense, because you stored $A2 to address $0600.

Then you click reset, which sends easy6502's CPU back to $0600. (Where the opcode for the first instruction should be.)
After the program is run, you get these values in A, X and Y:
Code:
A=$00 X=$a2 Y=$00

What is different in A, X and Y from when the program was run the first time?
Thinking about the explanation above, why do you think it ends up different?

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


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 12:25 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
I will try and read it fourth time...Again...

-Despite importance of this is very less, Program Counter allows you to to see where "you are now" on the location of the code.

-For HEX/Binary/number, it goes up by two. Because the opcode is stored into the assembly for the code to proceed, and the variables stored FOR/IN the opcode.

-For Address Code, it goes up by three. Because also the opcode is stored into the assembly for the code to proceed. BUT the Address has two separated numbers: high-byte and low-byte. the two separated numbers is two of three reasons for it to go up by three.

-Judging what you say about, "While writing and thinking about 6502 code, you basically never give any thought to the Program Counter. (Or at least, I don't!) It helps the CPU, but not you as the programmer that much." ---- This is less important for learning, but it's great to learn what this does. "I teach you about it now, so that you can better track the branching examples. Also, having learned it, you now know more than half of 6502 CPU's state!"

-BEQ/BNE is a new opcode I/you/we all will learn. It's a Lever-On-or-Off.

-BEQ: If the Zero Flag is turned on, while the code-line is onto BEQ, it will perform specific code upon it. OR it will go to the label of the code before returning here.
-If the Zero Flag is turned off, while the code-line is onto BEQ, it will be ignored and proceed like comment code.

-BNE is the polar opposite of BEQ. If Zero flag is OFF, while the code line is onto BNE, it will perform specific code, or go to label before returning here.
-If the Zero Flag is turned ON, while code line is onto BEQ, it will be ignored and proceed like comment code.

-Label is used to make re-using the code much faster and easier. And save a lot of spaces.

-----

? - Program Counter counts how many bytes you wasted. Potentially show you if you are wasting any memory to fit into NES or Mapper.

? - The High-Byte is $12. The Low-Byte is $34. The result is $1234.

X - The High-Byte and Low-Byte is not understood at this time for me.

========

I could see stern talk earlier. So I'm sorry if I was any rude to you. The Branching, at this time, is the hardest new lesson I had to see.

The best communication is to best understand each other.


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 1:59 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
What you've written about beq/bne is still not quite correct. Ignore the branching post.

Read this post: viewtopic.php?p=225445#p225445
And answer the questions at the bottom. Or ask questions about it.

Edit for the questions:
Quote:
-Despite importance of this is very less, Program Counter allows you to to see where "you are now" on the location of the code.

This is correct.
Quote:
-BEQ: If the Zero Flag is turned on, while the code-line is onto BEQ, it will perform specific code upon it. OR it will go to the label of the code before returning here.
-If the Zero Flag is turned off, while the code-line is onto BEQ, it will be ignored and proceed like comment code.

If the zero flag is turned on, while the code is on the line of the beq, it will go to the label next to it. There is no or. It also won't return.
If the zero flag is turned off, while the code is on the line of the beq, it will do nothing and proceed.

If the zero flag is turned on, it will do exactly one thing. If the zero flag is turned off, it will do exactly one thing. It can do one thing OR the other because the zero flag can be turned on OR turned off.

But given a turned on zero flag, it will always do one thing. And given a turned off zero flag, it will always do one thing.

Quote:
-Label is used to make re-using the code much faster and easier. And save a lot of spaces.

It makes it easier to read/write code because you don't have to memorize numbered addresses, but it saves no space at all.

Quote:
? - Program Counter counts how many bytes you wasted. Potentially show you if you are wasting any memory to fit into NES or Mapper.

No. Your other explanation was right. The explanation in the post was "The PC is the Program Counter. It keeps track of the address of the next instruction the CPU will execute." I'm not sure of a better way to make it clear.

The 6502 is very simple. I get the impression you've got it in your head that it can't be that simple, so you're trying to introduce new concepts to it. Basically everything related to 6502 does exactly one simple thing, keeps track of exactly one simple thing, or chooses between two simple things based on the state of one simple thing.

Quote:
? - The High-Byte is $12. The Low-Byte is $34. The result is $1234.

This is correct. Given $1234, the high byte is $12 and the low byte is $34. The 6502 would store them "backwards" like $34 $12, but they still represent $1234.

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


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 6:07 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
What is different in A, X and Y from when the program was run the first time?
Thinking about the explanation above, why do you think it ends up different?


My browser is Firefox atm.

Upon first running program:

A=$a2 X=$00 Y=$00
SP=$ff PC=$0606
NV-BDIZC
10110000

2nd time:

A=$00 X=$a2 Y=$00
SP=$ff PC=$0606
NV-BDIZC
10110000

3rd time [Press run 2 times]:

A=$00 X=$8d Y=$00
SP=$ff PC=$0604
NV-BDIZC
10110000

---
..........................I don't ever want this to be Bunnyboy nerdy nights all over again...............

The difference in running second time, is that upon reset, the tiny pieces of memories inside the CPU is still kept, and goes different ways because the memory from first run was partially kept, and then second memory..


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 7:01 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1243
I'll ask a more specific question.

Why does this specific code do something different each time you run it? It can't be just that memory is kept around, because no other code you've written or tried would get a different result after running it again. What is it about this code that makes it get a different result?

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


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 7:12 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
Kasumi wrote:
I'll ask a more specific question.

Why does this specific code do something different each time you run it? It can't be just that memory is kept around, because no other code you've written or tried would get a different result after running it again. What is it about this code that makes it get a different result?


:cry: :roll:

When you run the first time, the code is stored into Address $0600.

0600: a2 a2 8d 00 06 00 00 00 00 00 00 00 00 00 00 00

When you run the second time, while this code above is in there, it will give the same value, but in X instead of A.

Is this lesson well thought out for difficult thinking or is it trying to "prove me if I have what it takes to be part of NESDev or kick me out" test???


Top
 Profile  
 
PostPosted: Sun Sep 09, 2018 7:26 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 117
Is it because according to DISASSEMBLE on first time:

Address Hexdump Dissassembly
-------------------------------
$0600 a2 a2 LDX #$a2
$0602 8d 00 06 STA $0600

and on the second time:

Address Hexdump Dissassembly
-------------------------------
$0600 00 BRK
$0601 a2 8d LDX #$8d
$0603 00 BRK
$0604 06 00 ASL $00

There is an extra hidden code placed called BRK [Break Opcode], Load Data X, then ASL???

The BRK is a hidden opcode that appear out of nowhere when you reset the code?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 273 posts ]  Go to page Previous  1 ... 13, 14, 15, 16, 17, 18, 19  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