Page 18 of 24

Re: Hello, new here, and need best recommandations.

Posted: Thu Sep 13, 2018 5:20 pm
by DocWaluigean
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: Select all

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: Select all

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: Select all

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.

Re: Hello, new here, and need best recommandations.

Posted: Thu Sep 13, 2018 5:25 pm
by DocWaluigean
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.

Re: Hello, new here, and need best recommandations.

Posted: Thu Sep 13, 2018 7:33 pm
by Kasumi
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: Select all

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: Select all

; $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:
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: Select all

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.

Re: Hello, new here, and need best recommandations.

Posted: Thu Sep 13, 2018 10:55 pm
by DocWaluigean
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: Select all

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: Select all

; $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:
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: Select all

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: Select all


; 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. 

Re: Hello, new here, and need best recommandations.

Posted: Thu Sep 13, 2018 11:26 pm
by Kasumi
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.

Re: Hello, new here, and need best recommandations.

Posted: Fri Sep 14, 2018 11:14 am
by DocWaluigean

Code: Select all

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. 

Re: Hello, new here, and need best recommandations.

Posted: Fri Sep 14, 2018 11:59 am
by Kasumi
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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

ldx #$FF
dex
jmp continue
storecolor:
lda #$01
sta $0200
jmp end
addtox:
inx
continue:
dex
end:

Re: Hello, new here, and need best recommandations.

Posted: Fri Sep 14, 2018 1:19 pm
by DocWaluigean
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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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.

Re: Hello, new here, and need best recommandations.

Posted: Fri Sep 14, 2018 2:25 pm
by Kasumi
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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

restart:
ldx #$00
inx
beq restart
dex
bne restart
beq skip
lda #$00
beq restart
skip:

Code: Select all

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: Select all

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: Select all

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.)

Re: Hello, new here, and need best recommandations.

Posted: Fri Sep 14, 2018 3:19 pm
by unregistered
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.

Re: Hello, new here, and need best recommandations.

Posted: Sun Sep 16, 2018 7:49 pm
by DocWaluigean
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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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: Select all

restart:
ldx #$00
inx
beq restart
dex
bne restart
beq skip
lda #$00
beq restart
skip:

Code: Select all

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: Select all

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: Select all

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: Select all

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: Select all

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.

Re: Hello, new here, and need best recommandations.

Posted: Sun Sep 16, 2018 9:35 pm
by DocWaluigean
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.

Re: Hello, new here, and need best recommandations.

Posted: Sun Sep 16, 2018 9:36 pm
by DocWaluigean
Let see if I got at least 99% right on it...

*********************************************************************************************************
*********************************************************************************************************
*********************************************************************************************************





The limitations of 6502 CPU is 255. The HEX version is FF. The Binary version is 1111 1111 [or 11111111. Space in the middle helps a little?]

The number system in this style is wheels. It means if you go over 255, it will go back to 0.

6502 } 255 + 2 = 001.

It's the same thing in backwards. If you go below 0, it will go back to 255.

6502 } 3 - 5 = 254.

... 253, 254, 255, 0, 1, 2, ...
... 3, 2, 1, 0, 255, 254, 253, ...

Works either way.

The code line is always read from TOP to BOTTOM.





-------------------------
-------------------------
-------------------------


Any number / digit / variable / value = N
The "lever", or on [1] and off [0] = B



HEX number written >>> #$NN

Normal Number / Immediate Decimals number written >>> #NN

Binary number written >>> %$BBBBBBBB


Immediate Decimals Minimum Written = #N
Maximum usages Maximum Written = #NNN

----------

The Address [The location, destination, and objective of the code] >>> $NNNN

$NN = $00NN

$NNN = $0NNN

$N = 000N

$NNNN = $NNNN

The zeros is not used, while N is.





--------------------------
--------------------------
--------------------------

A label is a type of directive that makes it easier to go "back in time", or go directly to the label that's in the future OR the past of the codings using JMP/BEQ/BNE.

======EXAMPLES=====

cupcakes:
LDA $03

pancakes:
LDA $05

toilet:
LDA $FF
STA $FFFF


--

Think of something like a magical teleportation pod that said "@GOTO" with the name of the label in front of it. Except a little different.


***


A comment is a type of extremely simple code used to organize things. No matter how much you write in this, it will never be operated nor used inside the comment.

It's always a comment when it's after the [ ; ] symbol.

===EXAMPLES===

LDA $01 ; Yo man. Wanna go to a stag party?

LDX $02 ; Sounds dope, bruh! I hope I can bring some grasses in!

LDY $03 ; I happen to be a vegetarian! I'm so offended you mention grasses; my Dad was a tree trunk!

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

All the hilarious comments above will never be implemented into the code. So write whatever you want.








--------------------------
--------------------------
--------------------------






Register is simple number carrying system with fancy name that holds number, awaiting for commands to be replaced, or to placed.

The numbers never disappeared once assigned, or given a number, regardless. You always have to replace it to change the number/value/digit/variable.

With this, you can carry up to three numbers, maximum of 255 for each.

-----------

The limitations for each is:

A = You cannot increment, or fancy word of adding one, to the number stored into Register A directly. [INC/INX/INY] You have to do the INC to the Address that got the number from Register A to do that.

X/Y = You cannot transfer numbers from Register X and Y together. [TAX, TAY]
You can only transfer numbers from Y to A, and from X to A. But never X to Y and Y to X back again.







--------------------------
--------------------------
--------------------------






LDA / LDX / LDY - "Load Data into A/X/Y Register"

You put any number into the register A, X, or Y.

===EXAMPLE1===

LDA #$0F

STA $0001

---

A = 15 [The F number for HEX.]

"Put_Number_From_A_Into" Address-0001

The Address $0001 is now carrying number 15.


===EXAMPLE2===

LDX #13

STA $0030

---

X = 13

Address = 0030

The Address $0030 is now carrying number 13.

===EXAMPLE3===

LDY %#00001010

STA $13

---

Y = 10 [The number from Binary]

Address = 0013.

The Address $0013 is now carrying number 10.





--------------------------
--------------------------
--------------------------





TAX / TAY = Transfer Register A to X. or. Transfer Register A to Y.

TXA / TXY = Same thing as above, but other way.

Despite the name, the TXA/TXY/TAX/TAY copies the number from one register to another. It never loses its number, just copy.

If there is no program written in A/X/Y, nor any number placed into any Register, than it will copy to targeted Register as zero.


===EXAMPLE1===

LDA #$10

TAX

---

Register A is carrying number 15, or 10 in HEX number.

Register A has "transfer", or COPY, number 15 into Register X.

Right now, Register A and Register X has number 15 ready to be placed or replaced.

===EXAMPLE 2===

TAY

LDX #18

LDA #$FF

---

Register A has no number inside it, so it always has zero as default. As such, Register Y is now carrying number 0.

Register X is now carrying number 18.

Register A is now carrying 255 [FF in HEX number, the maximum for 8-bit.]

For this code:

A = 255
X = 18
Y = 0

===EXAMPLE 3===

LDA $01

TAX

TAY

LDY $05

TYA

---

Register A is now carrying number 1.

Register A is "copy and paste" number 1 for Register X ::: X is now carrying number 1.

Register A is also "copy and paste" number 1 for Register Y. ::: Y is also carrying number 1.

Register Y is being given number 5 to carry. Because Y already has number 1, it get's replaced and now it's number 5. ::: Y is now carrying number 5.

Register Y is "copying and paste" [TYA] number 5 for A.

A was carrying number 1, but as A is holding number 5 now, it replaces number 1 with number 5. ::: A is now carrying number 5 instead.

As a result from this ----

A = 5

X = 1

Y = 5





--------------------------
--------------------------
--------------------------



Increment - The smarty word for addition by one.

Decrement - The smarty word for subtraction from one.


INC / INX / INY = Increment, or add one, to the Address / Register X / Register Y.


***NOTICE***

For other programs, you could do INC STEP 2, INC STEP 5, to increment by addition of 2, or 5, or any number. Same thing with decrement.

But for 6502 Assembly, you can only do increment / decrement by 1.

************

===EXAMPLE1===

LDX #20

INX

---

X is now carrying number 20.

Increment X. Meaning you add by 1 to the X Register.

X is now carrying number 21.

===EXAMPLE2===

LDA $#0D

STA $0010

INC $0010

---

Put number 13 [D in HEX number] into Register A.

Store number 13 from Register A into Address $0010

Increment Address $0010 by one. It does NOT mean $0011! It only increments/decrements INSIDE the Address that the Register stored!

Address $0010 is now carrying 14.

===EXAMPLE3===

LDY #02

DEY

DEY

DEY

DEY

STY $1000

---

Put number 2 into Register Y.

Decrement Register Y FOUR times according to the code.

2 - 1 = 1

1 - 1 = 0

0 - 1 = 255

255 - 1 = 254

[The math is wrong, but it's right ONLY in 6502 CPU programming!]


Store number 254 from Register Y into Address $1000.

Now Address $1000 is holding number 254.






--------------------------
--------------------------
--------------------------






JMP = Jump.

This code will jump to any labels.

VERY simple, but can also be effective. An empty label will also work.

===EXAMPLES===



LDX $01

letsdoitagain:

INX

JMP letsdoitagain

---

Register X is now carrying number 1.

The label "letsdoitagain" is made.

Increment, or add 1, to Register X. Now carrying 2.

JMMP, [Jump] to the label letsdoitagain. Or in other words, "Go directly to the label named, "letsdoitagain" !!!"

You are now on the label "letsdoitagain".

Increment Register X, now carrying 3.

Jump to, or go to, the label "letsdoitagain".

IT NEVER ENDS!!!!!!!!

Re: Hello, new here, and need best recommandations.

Posted: Sun Sep 16, 2018 11:43 pm
by Kasumi
Your branch answers are correct. No thoughts on the number adding exercise?! Well, read on.
Binary number written >>> %$BBBBBBBB
It's '%'. (Usually. Many things depend on which assembler you use.)
easy6502 doesn't support binary at all, as far as I know.
'$' = hexadecimal.
'%' = binary.
Neither = decimal.
If you use '#' you want the value. If you leave out the '#' it's an address.
than it will copy to targeted Register as zero.
True in easy6502. Not really true in any other context, so do not rely on this. Never rely on any values in RAM/Addresses/Registers or otherwise that you didn't put there yourself, and that aren't a documented part of the hardware. Don't transfer from X without putting a known value there first, for example. Don't rely on RAM to be zero unless you are sure you stored zero there beforehand.

Some examples have read and copied from things without writing there first, but only so the focus could be on addresses rather than the values themselves.
Register A is carrying number 15, or 10 in HEX number.
$10 = 16, not 15.
===EXAMPLE 3===

LDA $01

TAX

TAY

LDY $05

TYA

---

Register A is now carrying number 1.
No. It's carrying the value inside address 1.
Register Y is being given number 5 to carry. Because Y already has number 1, it get's replaced and now it's number 5. ::: Y is now carrying number 5.
Also no. It's carrying the value inside address 5. If you don't precede the number with a '#' it's an address.
LDA $#0D
'#' has to be used before the '$'.
#$, not $#.
LDX $01

letsdoitagain:

INX

JMP letsdoitagain

---

Register X is now carrying number 1.
Nope, it's carrying the value inside address 1. I'm drilling this into your head now, it creates some obscure bugs if you don't get used to using # when you want to load a value rather than from an address.

I'm not sure I caught every error, but you totally do get it even if there are mistakes.


Anyway, next up is a new addressing mode (and a really tiny crash course on loops). We're finally getting back to the face. It's been a while, yeah?

Very early on, I mentioned how one of the differences between the registers are which instructions and addressing modes are available. And that some addressing modes wouldn't make sense for some registers. (Or, at least. I think I did! I'm not gonna look for it.)

We've done quite a lot with Absolute Addressing. That's lda $0000 or sta $0000. It deals with the value stored at the given address.

The next thing is, again, very simple. Absolute,x and Absolute,y addressing. They deal with the value stored in the address that is X or Y places away from the given address.

The syntax is LDA $????,x for absolute,x and LDA $????,y for absolute,y.
If X is zero, the result of absolute,x will be essentially identical to absolute addressing.
If Y is zero, the result of absolute,y will be essentially identical to absolute addressing.

Code: Select all

ldx #$00
ldy #$00

lda $0200;Fetch the value from address $0200.
lda $0200,x;Fetch the value from address $0200+x. Since X is 0, and $0200+0=$0200
;It will still fetch the value from address $0200.

lda $0201;Fetch the value fom address $0201.
lda $0201,y;Fetch the value from address $0201+y. Since Y is 0, and $0201+0=$0201
;It will still fetch the value from address $0201.
The magic happens when X or Y is not zero when you use the corresponding addressing mode.

I'll pause here to make one thing clear here. X or Y is added to the address itself, and then that address is used to get the actual value. X or Y is NOT added to the actual value stored inside the address.

Code: Select all

lda #$0F
sta $0200
lda #$02
sta $0201
lda #$08
sta $0202

ldx #1
lda $0200,x;A now holds the value 2. $0200+X (which holds 1) is $0201. Inside $0201 is #$02
inx;Now X = 2
lda $0200,x;A now holds the value 8. $0200+X (which holds 2) is $0202. Inside $0201 is #$08

Note that wrapping at 255 does NOT apply to the addition or X or Y to the address in this context.

Code: Select all

lda #$0B
sta $0300

ldy #$01
lda $02FF,y;$02FF+Y (which holds 1) is $0300. Inside $0300 is #$0B. So now A holds #$0B
So perhaps now you see one of the reasons for multiple registers. And also why they're slightly different. It'd be a bit weird to do LDY $0200,Y, but you can do LDY $0200,X.

What is this addressing mode useful for? It allows you to access data that is grouped in addresses. Remember how the pixels in easy6502 are in sequential addresses? Check out this code.

Code: Select all

lda #$02
ldx #$00
loop:
sta $0200,x
inx
bne loop
This makes 256 pixels of the screen red in easy6502. With your previous knowledge, you would have had to write 256 writes to do that. One for each pixel. Here there's only one write, used for all 256 pixels.

How does it work?
It gets the color to draw with in A.
It starts X with the value 0.
It stores the value in A to $0200+x, which colors one pixel red.
Then in adds one to X. Because 1 is not zero, it goes back to the loop label.
It stores the value in A to $0200+x. But because this time X is 1 and not zero, it is coloring a different pixel than before.

It does 256 pixels because eventually X gets to 255. The inx will then make it zero. And then the branch won't go to the label and the program ends.

This concept is a "loop" in programming. It's one of the fundamental concepts. They are usually set up to do the same (or nearly) the same operation on slightly different pieces of data.

And you may have already noticed how this will tie back to the face.
this post
Contains your code for the face. Any horizontal line can be done with a loop.

Let's take a look at how to turn your top horizontal line code:

Code: Select all

lda #$04
sta $0200
sta $0201
sta $0202
sta $0203
sta $0204
sta $0205
sta $0206
sta $0207
sta $0208
sta $0209
sta $020A
sta $020B
sta $020C
sta $020D
sta $020E
sta $020F
sta $0210
sta $0211
sta $0212
sta $0213
sta $0214
sta $0215
sta $0216
sta $0217
sta $0218
sta $0219
sta $021A
sta $021B
sta $021C
sta $021D
sta $021E
sta $021F
into a loop.

First, load X with how many pixels across the line is minus 1. (That is, if you want to draw 32 pixels, you must load X with 31). Then load A with the color you want. Then, store the value in A using absolute,x addressing (the address should be the one for the leftmost pixel in the horizontal line.) Then decrement X, and branch if not equal above the store. Immediately after the loop, store to the address of the leftmost pixel (using absolute addressing.)

Code: Select all

lda #$04
ldx #$1F
toplineloop:
sta $0200,x
dex
bne toplineloop
sta $0200
Way shorter, yes? And to briefly explain this one. Imagine you want to draw a 2 pixel line.
You'd load X with 1. After a single dex, there wouldn't be a branch and you've only drawn one pixel. So you draw the next one after the loop. If you had loaded X with 2, it would take two dex before the branches would stop. ETC.

Your assignment this time is to convert ALL horizontal lines in your old face code to loops like this.

PS: Perhaps this helps with the adding numbers exercise? :wink:

To be honest, I'm not entirely sure what to cover next. Most of the remaining concepts get a little denser, and I'm not sure which is best to do first.

There's pointers. (The two hardest addressing modes. One of two, I have actually never used, so I wouldn't teach it. The other one is super useful, but hard to explain immediately how. It's abstract...)

There's addition/subtraction/comparing. (This is easyish to give a quick explanation to, but hard to really cover.)

There's signed/unsigned numbers. (The above somewhat relies on this? Hmm...)

There's bitwise logic. (Easy so long as you don't overthink it)

And the stack. (easyish to give a quick explanation to, but hard to really cover...)

I'll think about it! I guess technically the addition circuit gives you the most fun tools, and starts to get meaty... and from there bitwise logic gets easier, with those then you'll know basically all the instructions.

Re: Hello, new here, and need best recommandations.

Posted: Mon Sep 17, 2018 1:59 pm
by unregistered
DocWaluigean wrote:
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.
Lumos Labs is a company; they provide a service; that service does help many people. :) People like my uncle, for instance, whose brain has improved. He has thanked me many times for introducing him to Lumosity. He says their service keeping all parts of his brain active helps him think more clearly when he needs it to... like when he runs his business/company, which provides service that helps people too. His business/company collects money too.

I used to have your mindset about Lumosity, but it vanished, for me, after being encouraged to think about this for a bit. :)