It is currently Sun Sep 23, 2018 3:10 am

All times are UTC - 7 hours





Post new topic Reply to topic  [ 275 posts ]  Go to page Previous  1 ... 15, 16, 17, 18, 19  Next
Author Message
PostPosted: Tue Sep 11, 2018 7:16 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1244
DocWaluigean wrote:
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 say this with sympathy, but all I can do is offer content. If the content can't be understood because of a real mental block, I can't realistically help. I don't have the training for it. I understand you're trying really hard, but I don't have infinite time or patience.

I can't do this forever. You've got another week of this. Ideally I'd like to get you to a point where you'll know enough to get past the blocks you've had in other online resources. Let's try to get there. We're going to take very small steps.

I have other things I need the time for. This doesn't mean no more help from nesdev at large, nor does it necessarily mean I won't answer any more questions, but I can't keep providing this level of attention forever.
---
Your answers are correct.

Except it's put the "number" from address $0200 into A, rather than the "numbers". It always is, and always will be just one 8 bit value.

Now it's time for labels again. All a label does is provide a name for the address of whatever byte is below it. So imagine there was a label above all the instructions I gave you.
Code:
label1:
lda #$00
label2:
sta $0201
label3:
tay
label4:
lda $0200
label5:

label1 is now a name for $0600.
label2 is now a name for $0602.
label3 is now a name for $0605.
label4 is now a name for $0606.
label5 is now a name for $0609.

As you can see, it matches what the Program Counter was when the 6502 CPU was about to run each instruction.

It's very simple, but just to prove you've got it, tell me what address each of the labels below would be a name for.
Code:
start:
ldx #$FF
afterload:
txa
aftertransfer:
tay
drawpixel:
stx $0200
changecolor:
inx
drawpixel2:
stx $0201
drawpixel3:
sty $0202

Use the format above for your answers.
"start" is now a name for ????
"afterload" is now a name for ???
etc.

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


Top
 Profile  
 
PostPosted: Wed Sep 12, 2018 3:55 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
DocWaluigean wrote:
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.
I understand... I did say that that Appendix wouldn't be instantly useable. :)

DocWaluigean wrote:
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.
Remember that MOS Technology created the 6502. This is their Appendix and yes, it's an old Appendix... but, it helped me to get more comfortable using concepts like "high byte" and it became so helpful to me after I became familiar with it and learned how to use it. 6502 assembly language requires you to problem solve tremendously. To start assembly problem solving you have to understand basic assembly concepts such as the addresses of instructions that Kasumi is helping you to learn. Assembly language is really powerful though (I explained why in a much earlier post in your thread). Something, at least, is wrong with everyone here... including me. I was diagnosed with Skitzophrenia and my medicine destroyed my brain but, now I'm doing much better!! PRAISE GOD!! :D Never give up and keep applying yourself. :)



edit: lumosity.com really helped and helps my brain. It's a brain training program where you spend money to sign up and then you are able to play all of their brain training games until your subscription expires... renew it just like a magazine subscription. It's run by Lumos Labs and they just added "ity" to the end of "lumos". Pretty cool/creative and that is an easy way to remember the url. :)


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 6:15 am 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 20565
Location: NE Indiana, USA (NTSC)
Or if you have a Nintendo DS or Nintendo 3DS, you could buy used copies of Brain Age and Big Brain Academy.


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 5:20 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
Kasumi wrote:
DocWaluigean wrote:
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 say this with sympathy, but all I can do is offer content. If the content can't be understood because of a real mental block, I can't realistically help. I don't have the training for it. I understand you're trying really hard, but I don't have infinite time or patience.

I can't do this forever. You've got another week of this. Ideally I'd like to get you to a point where you'll know enough to get past the blocks you've had in other online resources. Let's try to get there. We're going to take very small steps.

I have other things I need the time for. This doesn't mean no more help from nesdev at large, nor does it necessarily mean I won't answer any more questions, but I can't keep providing this level of attention forever.
---
Your answers are correct.

Except it's put the "number" from address $0200 into A, rather than the "numbers". It always is, and always will be just one 8 bit value.

Now it's time for labels again. All a label does is provide a name for the address of whatever byte is below it. So imagine there was a label above all the instructions I gave you.
Code:
label1:
lda #$00
label2:
sta $0201
label3:
tay
label4:
lda $0200
label5:

label1 is now a name for $0600.
label2 is now a name for $0602.
label3 is now a name for $0605.
label4 is now a name for $0606.
label5 is now a name for $0609.

As you can see, it matches what the Program Counter was when the 6502 CPU was about to run each instruction.

It's very simple, but just to prove you've got it, tell me what address each of the labels below would be a name for.
Code:
start:
ldx #$FF
afterload:
txa
aftertransfer:
tay
drawpixel:
stx $0200
changecolor:
inx
drawpixel2:
stx $0201
drawpixel3:
sty $0202

Use the format above for your answers.
"start" is now a name for ????
"afterload" is now a name for ???
etc.


I sadly understand, because your a living being, and your not a robot to do this forever. And as human beings, we all need some time for ourselves or for something far more important than lectures. So I guess I'm on my own again after 1 week? [You've got another week of this.] Try and understand I had to take break for 2 days due to personal anxiety. I'm back but possibly calm to learn and listen.

I understand most of it is my fault, but I don't know more words to say....It's personal and off-topic to blur out like I did earlier post.

---

Code:
start:                      ; $0600
ldx #$FF                    ; $0602
afterload:
txa                         ; $0604
aftertransfer:
tay                         ; $0606
drawpixel:
stx $0200                   ; $0609
changecolor:
inx                         ; $060B
drawpixel2:
stx $0201                   ; $060D
drawpixel3:
sty $0202                   ; $060F

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Address = 3 bytes. Opcodes = 2 bytes.


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 5:25 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
unregistered wrote:
DocWaluigean wrote:
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.
I understand... I did say that that Appendix wouldn't be instantly useable. :)

DocWaluigean wrote:
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.
Remember that MOS Technology created the 6502. This is their Appendix and yes, it's an old Appendix... but, it helped me to get more comfortable using concepts like "high byte" and it became so helpful to me after I became familiar with it and learned how to use it. 6502 assembly language requires you to problem solve tremendously. To start assembly problem solving you have to understand basic assembly concepts such as the addresses of instructions that Kasumi is helping you to learn. Assembly language is really powerful though (I explained why in a much earlier post in your thread). Something, at least, is wrong with everyone here... including me. I was diagnosed with Skitzophrenia and my medicine destroyed my brain but, now I'm doing much better!! PRAISE GOD!! :D Never give up and keep applying yourself. :)



edit: lumosity.com really helped and helps my brain. It's a brain training program where you spend money to sign up and then you are able to play all of their brain training games until your subscription expires... renew it just like a magazine subscription. It's run by Lumos Labs and they just added "ity" to the end of "lumos". Pretty cool/creative and that is an easy way to remember the url. :)


That's kind of true, but here's the differences; I'm on maximum legal dose in US of Sertraline [200mg?]..and it did absolutely nothing on me. People kept saying I'm waay smarter than I think I am, yet I keep struggling with self-learning things like this. If I get tutor for a month on artist, expect my name as lead director of the best Disney 2D animated movies. That's how fast I can learn if the teachings is really good and on pace. Let's just say, "My mind is too stubborn to stop suffering over something stupid."

Also, thanks on never giving up! And praise God too.

P.S. I don't trust Lumosity who uses knowledges and brain training for monetary gains. I agree on Brain Age though.


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 7:33 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1244
You're only on your own if everyone else stops answering your questions. You simply no longer get the same level of attention from me. By "a week", I meant a week from that post. Can I extend this to account for the break? Well, we'll see based on progress I guess. But the date wasn't really chosen arbitrarily, there are things happening near the 18th in my life.

Your answers are not correct. A label provides a name for the address of the byte below. It takes up no space by itself. Also remember "step"'s function is to run a single instruction, only. Labels aren't instructions.
Code:
start:
someotherlabel:
test:
lda #$00

We've talked about how in easy6502 the address for the first byte of the first instruction is usually at $0600. There are only two bytes in the example above. One for the opcode for lda # (which specifies the CPU should load the accumulator with the 8 bit value following the opcode). One for the operand $00. This means the address for the opcode is $0600. (And the address for the operand is $0601.)

Labels provide a name for the address of the byte below.
The byte below "test" is the first byte of the first instruction.
So "test" is a name for $0600.

"test" is below "someotherlabel", but "test" is a label. Because labels don't take up space by themselves, the byte below "someotherlabel" is also the first byte of the first instruction.
So "someotherlabel" is a name for $0600 as well.
"test" and "someotherlabel" are both below "start". But since labels don't take up space by themselves, the byte below "start" is also the first byte of the first instruction.
So "start" is a name for $0600 as well.

All three labels in the above example refer to the same address. (The address of the first instruction.) Try the other exercise again. Realize while you step through that labels aren't instructions, and "step" only runs instructions. So think about which instruction is about to be run. Then think about what label is above that instruction. And then you will have the label's address from the PC.

Edit: To perhaps explain it simpler:
Code:
; $0600;The address for the next byte
start:
; $0600;The address for the next byte                     
ldx #$FF                   
afterload:
txa                         
aftertransfer:
tay                         
drawpixel:
stx $0200                   
changecolor:
inx                         
drawpixel2:
stx $0201                 
drawpixel3:
sty $0202                 

Both start AND ldx #$FF get the same address, because a label's purpose is only to give a name to something to make things easier on you as a programmer. The CPU is actually unaware of what labels were/are there, they don't exist at all in the program the CPU executes.

Edit: One more note. TXA/TAY/INX are only one byte. You can use step to avoid having to do the address math manually. It's not a test for whether you know the size of the instructions by heart. Step will tell you through the address in the PC, the assignment only tests if you understand how a label gets which address it names.

Edit more: You can label it like you did before since it did help me see where the errors were coming from. But please ALSO use the format in the post for your final answers like the post requested:
Quote:
label1 is now a name for $0600.
label2 is now a name for $0602.
label3 is now a name for $0605.
label4 is now a name for $0606.
label5 is now a name for $0609.

Use the format above for your answers.
"start" is now a name for ????
"afterload" is now a name for ???
etc.

Otherwise there's room for some ambiguity.
Code:
lda #$FF;$0602;Does this mean the address for lda #$FF is $0602? Or does it mean the address for the byte below lda #$FF is $0602?

It's possible your only errors were instruction size, but the ambiguity of the format you used is why I specifically requested the format that I did.

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


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 10:55 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
Kasumi wrote:
You're only on your own if everyone else stops answering your questions. You simply no longer get the same level of attention from me. By "a week", I meant a week from that post. Can I extend this to account for the break? Well, we'll see based on progress I guess. But the date wasn't really chosen arbitrarily, there are things happening near the 18th in my life.

Your answers are not correct. A label provides a name for the address of the byte below. It takes up no space by itself. Also remember "step"'s function is to run a single instruction, only. Labels aren't instructions.
Code:
start:
someotherlabel:
test:
lda #$00

We've talked about how in easy6502 the address for the first byte of the first instruction is usually at $0600. There are only two bytes in the example above. One for the opcode for lda # (which specifies the CPU should load the accumulator with the 8 bit value following the opcode). One for the operand $00. This means the address for the opcode is $0600. (And the address for the operand is $0601.)

Labels provide a name for the address of the byte below.
The byte below "test" is the first byte of the first instruction.
So "test" is a name for $0600.

"test" is below "someotherlabel", but "test" is a label. Because labels don't take up space by themselves, the byte below "someotherlabel" is also the first byte of the first instruction.
So "someotherlabel" is a name for $0600 as well.
"test" and "someotherlabel" are both below "start". But since labels don't take up space by themselves, the byte below "start" is also the first byte of the first instruction.
So "start" is a name for $0600 as well.

All three labels in the above example refer to the same address. (The address of the first instruction.) Try the other exercise again. Realize while you step through that labels aren't instructions, and "step" only runs instructions. So think about which instruction is about to be run. Then think about what label is above that instruction. And then you will have the label's address from the PC.

Edit: To perhaps explain it simpler:
Code:
; $0600;The address for the next byte
start:
; $0600;The address for the next byte                     
ldx #$FF                   
afterload:
txa                         
aftertransfer:
tay                         
drawpixel:
stx $0200                   
changecolor:
inx                         
drawpixel2:
stx $0201                 
drawpixel3:
sty $0202                 

Both start AND ldx #$FF get the same address, because a label's purpose is only to give a name to something to make things easier on you as a programmer. The CPU is actually unaware of what labels were/are there, they don't exist at all in the program the CPU executes.

Edit: One more note. TXA/TAY/INX are only one byte. You can use step to avoid having to do the address math manually. It's not a test for whether you know the size of the instructions by heart. Step will tell you through the address in the PC, the assignment only tests if you understand how a label gets which address it names.

Edit more: You can label it like you did before since it did help me see where the errors were coming from. But please ALSO use the format in the post for your final answers like the post requested:
Quote:
label1 is now a name for $0600.
label2 is now a name for $0602.
label3 is now a name for $0605.
label4 is now a name for $0606.
label5 is now a name for $0609.

Use the format above for your answers.
"start" is now a name for ????
"afterload" is now a name for ???
etc.

Otherwise there's room for some ambiguity.
Code:
lda #$FF;$0602;Does this mean the address for lda #$FF is $0602? Or does it mean the address for the byte below lda #$FF is $0602?

It's possible your only errors were instruction size, but the ambiguity of the format you used is why I specifically requested the format that I did.


Happy Birthday? Wedding? New job? But sadly, I understand and I got to take responsibility for my lack of progress on past few days...I may repeat myself, but yeah. Mindset wise.
Or maybe I misread it again.

-

If I get this one wrong, I'll see if I could draw to see what's going on.
[Or maybe I'll draw this time.]

So label is the same power as the comment? Or it's to save time when re-using the code like:

AERIAL-MARIO:

LDA #$01

INC #$5000

IF #$FF

DEC #$5000

STA AERIAL-MARIO #$3000

??????????????????

------
Code:

; HEX = $00-FF : Binary = %$0000 - 1111 : Immediate Decimal = #$00-FF <=== ?????

start:                      ; $0600 --If this was NES, would it always start at $0000?--
ldx #$FF                    ; $0602 = 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.
afterload:                  ; $0602 = Labels; not wasting space at all no matter what.
txa                         ; $0603 = [i]TXA/TAY/INX are only one byte. [/i]
aftertransfer:              ; $0603 = Labels
tay                         ; $0604 = [i]TXA/TAY/INX are only one byte. [/i]
drawpixel:                  ; $0604 = Labels
stx $0200                   ; $0607 = 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.
changecolor:                ; $0607 = Labels
inx                         ; $0609 = 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.
drawpixel2:                 ; $0609 = Labels
stx $0201                   ; $060C = 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.
drawpixel3:                 ; $060C = Labels
sty $0202                   ; $060E = 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.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Address = 3 bytes. Opcodes = 2 bytes. TXA/TAY/INX = 1 byte.


Top
 Profile  
 
PostPosted: Thu Sep 13, 2018 11:26 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1244
Edit: I'm removing the reply with the answers to some questions, I feel it's getting off track. (It is saved locally so I can answer your questions later.) I am trying to give you less information at once so there's less to digest and be confused by.

Please use the format I requested for the answers. Again, the format you used is ambiguous. It looks like there are still a couple of errors (but again, ambiguity, please use the requested format or BOTH, not just what was used in your last post!).

The requested format is fill in the blank:
"start" is now a name for ????
"afterload" is now a name for ????
"aftertransfer" is now a name for ????
"drawpixel" is now a name for ????
"changecolor" is now a name for ????
"drawpixel2" is now a name for ????
"drawpixel3" is now a name for ????
Fill in the ???? for each line with the correct address.

I think the errors are primarily because you're doing the address math manually? Just step and look at the Program Counter. You have no need to memorize how big instructions are. The program counter will automatically skip the right number of bytes and just tell you the address for the next instruction that will be run.

I guess it wasn't quite right to say labels don't take up space. Label definitions don't. If you put a name in your code followed by a colon (like changecolor:), you have defined a label. Label definitions are sort of like comments in that the CPU doesn't know they existed when it's running the code.

But labels can also be used in place of an address in an instruction. "lda label" takes the same amount of space as "lda $0200" (assuming label was the name for $0200). We'll get to why they're useful and lots of other stuff you asked later when we start to use the labels. For now, it's important to understand how they're defined.

Then we can use them.

Then we can jmp.

Then we can branch.

edit: cleaned up some other wording.

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


Top
 Profile  
 
PostPosted: Fri Sep 14, 2018 11:14 am 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
Code:
start:         ; Name for $0600
ldx #$FF                   
afterload:     ; Name for $0602
txa                         
aftertransfer: ; Name for $0603
tay                         
drawpixel:     ; Name for $0604
stx $0200                   
changecolor:   ; Name for $0607
inx                         
drawpixel2:    ; Name for $0608
stx $0201                 
drawpixel3:    ; Name for $060B
sty $0202

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

; Address = 3 bytes. Opcodes = 2 bytes. TXA/TAY/INX = 1 byte.


Top
 Profile  
 
PostPosted: Fri Sep 14, 2018 11:59 am 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1244
Correct. Now for JMP, a new instruction. I "skipped" JMP because I wanted to try to get you to more interesting things which you craved, but this was probably a mistake.

Remember when I described "TXA" as like "LDA X" in that it copies the value from X into A?

Well, "JMP" is like LDPC. It copies the address that follows it into the Program Counter. (Except it copies the actual address, not the value stored at that address.)

The Program Counter (PC) stores the address of the next instruction to run. So this instruction effectively tells the CPU to start executing code at a different address than the one immediately below the instruction (unless the address you provide IS the one immediately below the instruction!). It's basically directly equivalent to GOTO.

Here is a simple example. Step through this code:
Code:
inx
lda #$FF

If you keep clicking step for it, the PC will keep going up to new places in memory.

Now step through this code:
Code:
inx
jmp $0600
lda #$FF

The first click of step will run the inx. The next click of step will run jmp $0600.
JMP copies $0600 into the PC, like I just described. Since the PC contains the address for the next instruction that will be run, this means the next instruction that will be run when you next click step is the one at address $0600. (Which like we've covered a few times, is usually the first instruction in easy6502. So here it's inx.)

If you keep clicking step, X will increase by 1 every other time. inx, jmp $0600, inx, jmp $0600. Forever. This is called an "infinite loop." Unlike the inx example that had no jmp, the program counter never gets a value higher than $0601. In this case, the jmp sends it back to an earlier address before it can get that high. This means that lda #$FF below the jmp is never executed. The PC never reaches its address.

And now, we get to one use of labels:
Code:
start:
inx
jmp start

If you know what instruction you want to run next, you just put a label above it. Then you can jmp to the label. And then you never need to figure out (or even know) the actual address for that instruction. And you can even put instructions before the label, and not have to update the jmp. (You would have to update the jmp if it were an address, because putting things before inx would give it a higher address. By putting things above the label, the label will get a new address automatically. Then things that use the label will use the address from the label. This is why no updates are needed.)
Code:
ldx #$80
start:
inx
jmp start


With labels, we can now basically forget about numbered addresses for code for the rest of forever.

Your next assignment: Tell me which instruction will be run after each of these jmps:
Code:
jmp storecolor;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Code:
jmp storezerotozero;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Code:
jmp addtox;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Finally, mark which instructions will NOT be run in the following code:
Code:
ldx #$FF
dex
jmp continue
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
continue:
dex
end:

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


Top
 Profile  
 
PostPosted: Fri Sep 14, 2018 1:19 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
Kasumi wrote:
Correct. Now for JMP, a new instruction. I "skipped" JMP because I wanted to try to get you to more interesting things which you craved, but this was probably a mistake.

Remember when I described "TXA" as like "LDA X" in that it copies the value from X into A?

Well, "JMP" is like LDPC. It copies the address that follows it into the Program Counter. (Except it copies the actual address, not the value stored at that address.)

The Program Counter (PC) stores the address of the next instruction to run. So this instruction effectively tells the CPU to start executing code at a different address than the one immediately below the instruction (unless the address you provide IS the one immediately below the instruction!). It's basically directly equivalent to GOTO.

Here is a simple example. Step through this code:
Code:
inx
lda #$FF

If you keep clicking step for it, the PC will keep going up to new places in memory.

Now step through this code:
Code:
inx
jmp $0600
lda #$FF

The first click of step will run the inx. The next click of step will run jmp $0600.
JMP copies $0600 into the PC, like I just described. Since the PC contains the address for the next instruction that will be run, this means the next instruction that will be run when you next click step is the one at address $0600. (Which like we've covered a few times, is usually the first instruction in easy6502. So here it's inx.)

If you keep clicking step, X will increase by 1 every other time. inx, jmp $0600, inx, jmp $0600. Forever. This is called an "infinite loop." Unlike the inx example that had no jmp, the program counter never gets a value higher than $0601. In this case, the jmp sends it back to an earlier address before it can get that high. This means that lda #$FF below the jmp is never executed. The PC never reaches its address.

And now, we get to one use of labels:
Code:
start:
inx
jmp start

If you know what instruction you want to run next, you just put a label above it. Then you can jmp to the label. And then you never need to figure out (or even know) the actual address for that instruction. And you can even put instructions before the label, and not have to update the jmp. (You would have to update the jmp if it were an address, because putting things before inx would give it a higher address. By putting things above the label, the label will get a new address automatically. Then things that use the label will use the address from the label. This is why no updates are needed.)
Code:
ldx #$80
start:
inx
jmp start


With labels, we can now basically forget about numbered addresses for code for the rest of forever.

Your next assignment: Tell me which instruction will be run after each of these jmps:
Code:
jmp storecolor;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Code:
jmp storezerotozero;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Code:
jmp addtox;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


Finally, mark which instructions will NOT be run in the following code:
Code:
ldx #$FF
dex
jmp continue
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
continue:
dex
end:


FINALLY a good one. This might be fun!

====================1======================

So JMP = "Go Directly To" "[Address/Labels/???]

Code:
jmp storecolor; Which instruction will be run after this jmp runs?
storecolor: ; The destination of where JMP wants from the first line!
lda #$01
sta $0200
jmp end ; Go directly to "end" label.
addtox:
inx
jmp end ; Go directly to "end" label.
storezerotozero:
lda #$00
sta $0000
end:


=======================2====================
Code:
jmp storezerotozero;Which instruction will be run after this jmp runs?
storecolor: ; label. [It's ignored because JMP's fault.]
lda #$01
sta $0200
jmp end
addtox:
inx
jmp end
storezerotozero: ; The destination where JMP wants from first line!
lda #$00
sta $0000
end:


======================3======================
Code:
jmp addtox;Which instruction will be run after this jmp runs?
storecolor:
lda #$01
sta $0200
jmp end
addtox: ; The destination of where the JMP wants you to go from first line!
inx
jmp end
storezerotozero:
lda #$00
sta $0000
end:


======================4=========================

Ooooohoohooohoohoo, you trying to trick me, huh?!

Code:
ldx #$FF ; Load number 255 into Register X
dex ; decrement / subtract 1 from Register X.
jmp continue ; Go directly to "continue" label.
storecolor: ; IGNORE!!! ALL CODE IN STORECOLOR IS A BAD BOY!
lda #$01 ;IGNORE!!!
sta $0200 ;IGNORE!!!
jmp end ;IGNORE!!!
addtox: ;IGNORE!!!
inx ;IGNORE!!!
continue: The destination where JMP wants you to go!
dex ; decrement / subtract 1 from Register X.
end: ; label. Nothing happens.


Top
 Profile  
 
PostPosted: Fri Sep 14, 2018 2:25 pm 
Offline
User avatar

Joined: Wed Apr 02, 2008 2:09 pm
Posts: 1244
And again, all correct! Seems you're getting this. It's really is mostly simple, small pieces you just have to not overthink it. Though there are some complicated things upcoming.

Let's get back to branching. If this post sounds familiar, it's because it's actually mostly copy-pasted from the last post.

BEQ is Branch on EQual (to zero). It will jmp ("branch") to the address/label specified after the BEQ instruction if the zero flag is set. Otherwise, it will go to the next instruction like we've gotten used to happening.

This means if the zero flag is set when the instruction is run, it is equivalent to jmp. (Except... for an exception we'll get to.)
Otherwise, it decides to do nothing and the instruction below it will be run next.


Here is a simple example:
Code:
restart:
lda #$00;This sets the zero flag
beq restart
lda #$FF

Now step through the code above and watch the Program Counter. It will start at $0600. (the address for lda #$00). Then it will go to $0602 (the address for beq restart). But if you step again, something new happens! Rather than get higher, it goes back to $0600! Keep stepping and it will alternate between $0600 and $0602! The lda #$FF will never be reached or executed by the CPU.

The above example sets the zero flag by loading zero, then follows it with a branch that triggers if the zero flag is set. Because the zero flag is set, it goes to the address specified, effectively restarting the program. That demonstrated how BEQ is like JMP when the zero flag is set.

Let's modify that example slightly.
Code:
restart:
lda #$80;This clears the zero flag
beq restart
lda #$FF


Step through that one. The PC starts at $0600 (lda #$80) like before. It goes to $0602 (beq restart) like before. But stepping again DOES continue to go up. It goes to $0604 (lda #$FF). This time, the lda #$FF is reached. That example demonstrates how it goes to the next instruction when the zero flag is clear.

BNE is Branch if Not Equal (to zero). It will jmp ("branch") to the address/label specified after the BNE instruction if the zero flag is clear. Otherwise, it will go to the next instruction like how most other instructions work.

Let's try it in the example code, in place of BEQ.
Code:
restart:
lda #$00;This sets the zero flag
bne restart
lda #$FF

This does NOT branch, and the lda #$FF IS reached because bne branches when the zero flag is clear, and beq branches when the zero flag is set.
Code:
restart:
lda #$80;This clears the zero flag
bne restart
lda #$FF

This DOES branch, and the lda #$FF is NOT reached.

One more note: You can branch forward. (Just like you can jmp forward.)
Code:
lda #$FF;The zero flag is clear
bne skip;Because the zero flag is clear, we branch to the skip label
lda #$04;This is never executed
skip:

Your assignment is to comment each branch with whether or not it will branch, and why. Also mark any code the CPU will never execute (get to).
Code:
restart:
ldx #$00
inx
beq restart
dex
bne restart
beq skip
lda #$00
beq restart
skip:


Code:
restart:
ldy #$04
dey
beq restart
dey
beq restart
dey
beq restart
dey
beq restart
dey
beq restart


I'll end with this. You technically have all the information you need to write a program that adds two numbers. (Granted, there's a way better way to do it with things you do not yet know!) The last example (with all the dey instructions) is a part of the key. Do you notice any correspondence between the value Y starts with and how it ends up branching? Count some things!

And now, think about how you might write a program that adds the number in X and the number in Y together, and stores the result in $00. Assume the values you'll be adding will be 1, 2, 3, or 4. So before your code would be
Code:
ldx #$??
ldy #$??
;Your code here

Where each ?? could be any of those 4 values. Your program would store the added result in $00. So if your program was given:
Code:
ldx #$03
ldy #$01
;Your code here

After "Your code here" runs, #$04 would be held by ram location $00.

The adding numbers it not a required assignment to complete. It's actually pretty difficult. But I do want you to give it some serious thought. Reason about it. You do know all the tools needed complete the task. Even if you don't get it, write out some things you thought about or tried.

(And again, for the technically minded reading, yes, I realize some ways this might be solved and it's why I'm limiting the input to 1, 2, 3 and 4 and leaving 0 out of the picture so as not to make the code super tedious to write even for the "larger" solutions.)

Since the adding numbers task is difficult, I will leave you some KING SIZE hints. You know how to set the value stored in an address to a specific value. And you know how to add one to the value stored inside an address. So the only thing you have to figure out is how to add one to address a specific number of times.

(PS, I won't be around too much for tonight, but this gives you time to reason about the number adding exercise.)

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


Top
 Profile  
 
PostPosted: Fri Sep 14, 2018 3:19 pm 
Offline
User avatar

Joined: Thu Apr 23, 2009 11:21 pm
Posts: 927
Location: cypress, texas
DocWaluigean wrote:
That's kind of true,
I was going to say I was only speaking truth about my life but, now I realize that you ment, "That's kind of true about me," :)

DocWaluigean wrote:
Also, thanks on never giving up! And praise God too.
You're welcome. :) And :D

DocWaluigean wrote:
P.S. I don't trust Lumosity who uses knowledges and brain training for monetary gains. I agree on Brain Age though.
Lumos Labs spent and spends lots of time creating the many brain training games that improve my brain. They also bought and maintain the countless servers that allow Lumosity users all over the world to log in and train their brains daily, if people want to. They created LPI Lumosity Points Index which is a number that helps each user to know how well their brain is doing. They employ a help center staff that answers questions. It's a pretty extravagant outreach to help us improve our brains and it's very helpful and so much fun, for me, so I am more than happy to spend the subscription fee. That's why I recommend the service. :)

Brain Age is cheaper, but, for me, it's like eating sand. Sand is not nutritious for me. I seriously hope Brain Age helps you tons more than it helped me. :) And it could, I guess, cause I've been playing Lumosity and haven't played Brain Age in many years.

eoLumosity talk.


Top
 Profile  
 
PostPosted: Sun Sep 16, 2018 7:49 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
Kasumi wrote:
And again, all correct! Seems you're getting this. It's really is mostly simple, small pieces you just have to not overthink it. Though there are some complicated things upcoming.

Let's get back to branching. If this post sounds familiar, it's because it's actually mostly copy-pasted from the last post.

BEQ is Branch on EQual (to zero). It will jmp ("branch") to the address/label specified after the BEQ instruction if the zero flag is set. Otherwise, it will go to the next instruction like we've gotten used to happening.

This means if the zero flag is set when the instruction is run, it is equivalent to jmp. (Except... for an exception we'll get to.)
Otherwise, it decides to do nothing and the instruction below it will be run next.


Here is a simple example:
Code:
restart:
lda #$00;This sets the zero flag
beq restart
lda #$FF

Now step through the code above and watch the Program Counter. It will start at $0600. (the address for lda #$00). Then it will go to $0602 (the address for beq restart). But if you step again, something new happens! Rather than get higher, it goes back to $0600! Keep stepping and it will alternate between $0600 and $0602! The lda #$FF will never be reached or executed by the CPU.

The above example sets the zero flag by loading zero, then follows it with a branch that triggers if the zero flag is set. Because the zero flag is set, it goes to the address specified, effectively restarting the program. That demonstrated how BEQ is like JMP when the zero flag is set.

Let's modify that example slightly.
Code:
restart:
lda #$80;This clears the zero flag
beq restart
lda #$FF


Step through that one. The PC starts at $0600 (lda #$80) like before. It goes to $0602 (beq restart) like before. But stepping again DOES continue to go up. It goes to $0604 (lda #$FF). This time, the lda #$FF is reached. That example demonstrates how it goes to the next instruction when the zero flag is clear.

BNE is Branch if Not Equal (to zero). It will jmp ("branch") to the address/label specified after the BNE instruction if the zero flag is clear. Otherwise, it will go to the next instruction like how most other instructions work.

Let's try it in the example code, in place of BEQ.
Code:
restart:
lda #$00;This sets the zero flag
bne restart
lda #$FF

This does NOT branch, and the lda #$FF IS reached because bne branches when the zero flag is clear, and beq branches when the zero flag is set.
Code:
restart:
lda #$80;This clears the zero flag
bne restart
lda #$FF

This DOES branch, and the lda #$FF is NOT reached.

One more note: You can branch forward. (Just like you can jmp forward.)
Code:
lda #$FF;The zero flag is clear
bne skip;Because the zero flag is clear, we branch to the skip label
lda #$04;This is never executed
skip:

Your assignment is to comment each branch with whether or not it will branch, and why. Also mark any code the CPU will never execute (get to).
Code:
restart:
ldx #$00
inx
beq restart
dex
bne restart
beq skip
lda #$00
beq restart
skip:


Code:
restart:
ldy #$04
dey
beq restart
dey
beq restart
dey
beq restart
dey
beq restart
dey
beq restart


I'll end with this. You technically have all the information you need to write a program that adds two numbers. (Granted, there's a way better way to do it with things you do not yet know!) The last example (with all the dey instructions) is a part of the key. Do you notice any correspondence between the value Y starts with and how it ends up branching? Count some things!

And now, think about how you might write a program that adds the number in X and the number in Y together, and stores the result in $00. Assume the values you'll be adding will be 1, 2, 3, or 4. So before your code would be
Code:
ldx #$??
ldy #$??
;Your code here

Where each ?? could be any of those 4 values. Your program would store the added result in $00. So if your program was given:
Code:
ldx #$03
ldy #$01
;Your code here

After "Your code here" runs, #$04 would be held by ram location $00.

The adding numbers it not a required assignment to complete. It's actually pretty difficult. But I do want you to give it some serious thought. Reason about it. You do know all the tools needed complete the task. Even if you don't get it, write out some things you thought about or tried.

(And again, for the technically minded reading, yes, I realize some ways this might be solved and it's why I'm limiting the input to 1, 2, 3 and 4 and leaving 0 out of the picture so as not to make the code super tedious to write even for the "larger" solutions.)

Since the adding numbers task is difficult, I will leave you some KING SIZE hints. You know how to set the value stored in an address to a specific value. And you know how to add one to the value stored inside an address. So the only thing you have to figure out is how to add one to address a specific number of times.

(PS, I won't be around too much for tonight, but this gives you time to reason about the number adding exercise.)


I wasn't here few days ago because I had therapy and other big personal assistance that needed me.

---------1---------
Code:
restart:
ldx #$00 ; Put 0 into Register X; Zero Flag turn on.
inx ; Add 1 into Register X; now Zero Flag turn off.
beq restart ; Zero Flag is not on, this does NOTHING.
dex ; Subtract 1 from Register X; now Zero Flag turns on.
bne restart ; Zero Flag is turn on, this also does NOTHING.
beq skip ; Zero Flag is turn on; this means, "Go Directly to label "skip"!

;---WORTHLESS---;
lda #$00 ; Load 0 into Register A.
beq restart ; Go to restart label if the Zero Flag is turned on.
;---WORTHLESS---;
skip:


-----------------2-----------------

Code:
restart:
ldy #$04 ; Load, or put, number 4 into Register Y.
dey ; Decrement, or subtract 1, from Register Y.
;Now Y = 3
beq restart ; Ignored, because Zero Flag is turned off. [Y = 4 does NOT work for BEQ. As 4 != 0, or 4 not equal to zero.]
dey ; Decrement, or subtract 1, from Register Y...Again.
; Y = 2
beq restart ; Ignored, because Zero Flag is turned off. [2 != 0]
dey ; Subtract 1 from Register Y.
beq restart ; Ignored; 1 != 0.
dey ; Subtract 1 from Register Y.
; Y = 0, so the Zero Flag is turned on.
beq restart ; Because the Zero Flag is turned on, BEQ now works : Go directly to label "restart".

;Y = 0 = 0 = Y

;---WORTHLESS---;
dey ; Subtract 1 from Register Y.
beq restart ; If Zero Flag is turned on, go directly to label "restart."
;---WORTHLESS---;


This is going to be VERY interesting to make cartoons to teach people, and kids, about this programming.


Top
 Profile  
 
PostPosted: Sun Sep 16, 2018 9:35 pm 
Offline

Joined: Sun Jun 17, 2018 6:41 pm
Posts: 118
unregistered wrote:
DocWaluigean wrote:
That's kind of true,
I was going to say I was only speaking truth about my life but, now I realize that you ment, "That's kind of true about me," :)

DocWaluigean wrote:
Also, thanks on never giving up! And praise God too.
You're welcome. :) And :D

DocWaluigean wrote:
P.S. I don't trust Lumosity who uses knowledges and brain training for monetary gains. I agree on Brain Age though.
Lumos Labs spent and spends lots of time creating the many brain training games that improve my brain. They also bought and maintain the countless servers that allow Lumosity users all over the world to log in and train their brains daily, if people want to. They created LPI Lumosity Points Index which is a number that helps each user to know how well their brain is doing. They employ a help center staff that answers questions. It's a pretty extravagant outreach to help us improve our brains and it's very helpful and so much fun, for me, so I am more than happy to spend the subscription fee. That's why I recommend the service. :)

Brain Age is cheaper, but, for me, it's like eating sand. Sand is not nutritious for me. I seriously hope Brain Age helps you tons more than it helped me. :) And it could, I guess, cause I've been playing Lumosity and haven't played Brain Age in many years.

eoLumosity talk.


Ya didn't mention the sandwich, did ya?

Also, there's a question I got for you: Imagine a world without free knowledge. Would you love it?
It's good there's Lumosity about it, but it's also bad making profit by forces about it excluding free trials when it should really help the people instead.


Last edited by DocWaluigean on Sun Sep 16, 2018 9:38 pm, edited 1 time in total.

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

All times are UTC - 7 hours


Who is online

Users browsing this forum: Google [Bot] 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